Enable the export of custom facets to a CSV file

Last updated Tuesday, September 6, 2016 in Sitecore Experience Platform for Administrator
Keywords: Configuration, Contacts

You can create custom contact facets to include contact information that your organization wants to track, for example, addresses, country, or company.

If you want these custom contact facets to appear in the CSV file when you export lists of contacts from the List Manager, you must configure the listManagement.exportContacts pipeline.

Note

Make sure to index new custom contact facets before you export them from the List Manager.

To enable the export of custom facets to a CSV file:

  1. Create a new GetCustomContactRows class, making sure it is inherited from the existing class Sitecore.ListManagement.ContentSearch.Pipelines.ExportContacts.GetContactRows, Sitecore.ListManagement.ContentSearch.

    Override the protected GetRow method to export the relevant facets, for example, Company.

     public class GetCustomContactRows : GetContactRows
      {
        protected override IEnumerable<string> GetRow(IEnumerable<ContactData> contacts)
        {
          Assert.ArgumentNotNull(contacts, "contacts");
          var sep = this.Delimiter.ToString(CultureInfo.InvariantCulture);
          yield return string.Join(sep, "Identifier", "FirstName", "Surname", "Email", "Company");
          foreach (var contact in contacts)
          {
            yield return string.Join(sep,
              contact.Identifier, contact.FirstName, contact.Surname,
              contact.PreferredEmail, contact["contact.Company"]);
          }
        }
      }
  2. In the App_Config\Include\ListManagement\Sitecore.ListManagement.config file, in the listManagement.exportContacts pipeline, delete the existing GetContactRows processor and register the new one:
    <listManagement.exportContacts>
      <processor    type="<custom namespace>.GetCustomContactRow, <custom assembly>" />
      <processor type="Sitecore.ListManagement.ContentSearch.Pipelines.ExportContacts.GetContactsStream, Sitecore.ListManagement.ContentSearch" />
    </listManagement.exportContacts>
Send feedback about the documentation to docsite@sitecore.net.