To add OOTB Facet field to the CSV file:
using Sitecore.ListManagement.XConnect.Web.Export;
using Sitecore.XConnect;
using Sitecore.XConnect.Collection.Model;
namespace YourProject
{
public class PhoneNumber : IContactDataReader
{
public string FacetName => PhoneNumberList.DefaultFacetKey;
public string Map(Contact contact)
{
var phoneNumberList = contact.GetFacet<PhoneNumberList>(PhoneNumberList.DefaultFacetKey);
string phoneNumber = $"{phoneNumberList.PreferredPhoneNumber.CountryCode}{phoneNumberList.PreferredPhoneNumber.Number}";
return phoneNumber;
}
}
}
To add a Custom Facet field to the CSV file:
using Sitecore.ListManagement.XConnect.Web.Export;
using Sitecore.XConnect;
// Add reference containing definition for Custom Facet
namespace YourProject
{
public class CustomFacetField : IContactDataReader
{
public string FacetName => CustomFacetName.DefaultFacetKey;
public string Map(Contact contact)
{
var customFacet = contact.GetFacet<CustomFacetName>(CustomFacetName.DefaultFacetKey);
string customFacetFieldName = customFacet.CustomFacetFieldName;
return customFacetFieldName;
}
}
}
The final step is to patch the App_Config/Sitecore/ListManagement/Sitecore.ListManagement.config
with your own config file.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<listManager>
<export>
<field name="PhoneNumber" type="YourProject.PhoneNumber, YourProject" />
<field name="CustomFacetField" type="YourProject.CustomFacetField, YourProject" />
</export>
</listManager>
</sitecore>
</configuration>
For detailed explanation, check out this article.