I'm trying to extend an existing import mapper to include custom contact facets.this is the code I used following the documentation of sitecore 9.1 https://doc.sitecore.com/users/91/sitecore-experience-platform/en/configure-the-import-contacts-wizard-to-include-custom-contact-facets.html
this is my new class that represents the new extended mapper:
namespace CustomFacet
{
public class ExtendedEmailFacetMapperSample : IFacetMapper
{
private readonly PreferredEmailFacetMapper mapper;
// Decorate the existing PreferredEmailMapper
public ExtendedEmailFacetMapperSample(
PreferredEmailFacetMapper mapper)
{
this.mapper = mapper;
}
public MappingResult Map(string facetKey, Sitecore.XConnect.Facet facet, ContactMappingInfo mappings, string[] data)
{
// Call the existing email mapper to map all the basic email fields
var result = this.mapper.Map(facetKey, facet, mappings, data);
var facetMappedResult = result as FacetMapped;
if (facetMappedResult == null)
{
return result;
}
var partiallyMappedFacet = facetMappedResult.Facet as EmailAddressList;
if (partiallyMappedFacet == null)
{
return result;
}
// Set Personal email
var personalEmail = mappings.GetValue("PersonalEmail", data);
if (!string.IsNullOrWhiteSpace(personalEmail))
{
partiallyMappedFacet.Others["Personal"] = new EmailAddress(personalEmail, false);
}
// Set Work email
var workEmail = mappings.GetValue("WorkEmail", data);
if (!string.IsNullOrWhiteSpace(workEmail))
{
partiallyMappedFacet.Others["Work"] = new EmailAddress(workEmail, false);
}
return result;
}
}
}
and then I Registered the facet mapper in the Sitecore.ListManager.config file under the sitecore/import/facetMapper section:
<facetMappers hint="list:Add">
<facetMapper type="Sitecore.ListManagement.XConnect.Web.Import.ListSubscriptionMapper, Sitecore.ListManagement.XConnect.Web" />
<facetMapper type="Sitecore.ListManagement.XConnect.Web.Import.PreferredAddressFacetMapper, Sitecore.ListManagement.XConnect.Web" />
<facetMapper type="Sitecore.ListManagement.XConnect.Web.Import.PreferredEmailFacetMapper, Sitecore.ListManagement.XConnect.Web" />
<facetMapper type="Sitecore.ListManagement.XConnect.Web.Import.PersonalInformationFacetMapper, Sitecore.ListManagement.XConnect.Web" />
<facetMapper type="CustomFacet.ExtendedEmailFacetMapperSample, CustomFacet">
<param type="Sitecore.ListManagement.XConnect.Import.PreferredEmailFacetMapper, Sitecore.ListManagement.XConnect" />
</facetMapper>
</facetMappers>
but it results in this exception :
Exception Sitecore.Exceptions.ConfigurationException: Could not create instance of type: CustomFacet.ExtendedEmailFacetMapperSample. No matching constructor was found.