0

Using Sitecore 9.1.1 - we have a custom facet that we want to update using the List Manager import.

Following the sample on this page, to map a CSV field to this custom facet it seems to be the case of simply updating the core database ImportModel for the ImportWizard Dialog. https://doc.sitecore.com/users/91/sitecore-experience-platform/en/configure-the-import-contacts-wizard-to-include-custom-contact-facets.html

However, the value of my custom facet is never saved against the existing contact.

It's definitely matching on the contact because I can see updates to the first name and last name based on importing, just not on the custom facet.

Any tips on what might have been missed?

This contact definitely has this facet already (although even if it didn't - I would hope that it would add it with the appropriate value).

My ImportModelField:

enter image description here

The contactFacet in the database where the value doesn't change. enter image description here

Is it sufficient just to add the core database entry - or do I also need a custom mapper class for my custom facet EmailData?

2
  • 1
    You need to follow the rest of the linked article and write the code for the import mapper. Dec 10 '19 at 6:08
  • @MarkGibbons yep - managed to get that advice and implement so now all sorted. thanks :)
    – Jen
    Dec 11 '19 at 2:11
0

In case anyone else is looking for the answer - turns out I had to:

  • create a mapper class for my custom facet, implementing IFacetMapper
  • remember to handle the facet potentially being null for the contact in question
  • patch in the mapper class, and add my custom facet to the FacetsToMap element.
0

To add a new facet as a mapping field:

  1. In the Core database, in the Content Editor, navigate to the /sitecore/client/Applications/List Manager/Dialogs/ImportWizardDialog/PageSettings/TabControl Parameters/Map/ImportModel folder and Create a new Import model field item based on the /sitecore/client/Applications/List Manager/Templates/ImportModelField template.
  2. In the FieldName field, specify the name of the Sitecore mapping field to display in the Import contacts wizard. In the DataField field, specify the key that the Facet Mapper uses to recognize the xConnect facet property of where to store the imported value. eg. CustomerStatus is the custom facet that I want to map.

enter image description here

  1. Now create a custom import mapper class implementing Sitecore.ListManagement.XConnect.Web.Import.IFacetMapperSitecore.ListManagement.Import.IFacetMapper. Build this project and deploy the DLL to Sitecore root bin folder.
class CustomerStatusFacetMapper: IFacetMapper
    {
        private const string FacetMapperPrefix = "CustomerStatus_";
 
        public CustomerStatusFacetMapper() : this("CustomerStatus")
        {
        }
        public CustomerStatusFacetMapper(string facetName)
        {
            Assert.ArgumentNotNull(facetName, nameof(facetName));
 
            this.FacetName = facetName;
        }
        public string FacetName { get; }
 
        public MappingResult Map(string facetKey, Facet facet, ContactMappingInfo mappings, string[] data)
        {
            using (EventLog eventLog = new EventLog("Application"))
            {
                eventLog.Source = "Application";
                eventLog.WriteEntry("CustomerFacetMapperCalled facetKey:" + facetKey + " data" + string.Join("; ", data));
            }
 
            if (facetKey != this.FacetName)
            {
                return new NoMatch(facetKey);
            }
 
            CustomerStatus customeruser = new CustomerStatus();
            string customerStatus = mappings.GetValue(FacetMapperPrefix+nameof(customeruser.Status), data);
            Log.Info("Facet Mapper: " + FacetMapperPrefix + nameof(customeruser.Status), this);
            if (!string.IsNullOrEmpty(customerStatus)) { customeruser.Status = customerStatus; }
            return (MappingResult)new FacetMapped(facetKey, (Facet)customeruser);
 
        }
    }
  1. Create a patch to register the mapper. This patch is extending Sitecore.ListManagement.config file (/App_Config/Sitecore/ListManagement), sitecore/import/facetMapper section. Add the custom facet name to extend the list of facets to map to.
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"
               xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore role:require="Standalone or ContentManagement">
    <settings>
      <setting name="ListManagement.Import.FacetsToMap" value="Emails|Personal|Addresses|CustomerStatus" />
    </settings>
    
    <import>
      <facetMapper type="Sitecore.ListManagement.XConnect.Web.Import.CompositeFacetMapperCollection, Sitecore.ListManagement.XConnect.Web">
        <param resolve="true" type="Sitecore.Abstractions.BaseLog, Sitecore.Kernel"/>
        <facetMappers hint="list:Add">
          <facetMapper type="MA.CustomMarketingApps.Mappers.CustomerStatusFacetMapper, MA.CustomMarketingApps" />
        </facetMappers>
      </facetMapper>
    </import>
  </sitecore>
</configuration>
  1. Now in the ListManager dashboard, create a list from the file. And browse for CSV (CSV should have data against headers Email, FirstName, LastName, NickName, CustomerStatus), Map the fields. enter image description here After doing all these, you'll be able to correctly import custom facets via list manager CSV upload.

Refer to this blog for more details: https://sitecorewithraman.wordpress.com/2021/03/27/customize-list-manager-part-ii/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.