Walkthrough: Creating a custom contact facet
In Sitecore Experience Platform, you use contact facets to store data on contacts. This walkthrough guides you through the process of creating a custom contact facet and configuring the synchronization process to populate the facet with data from Salesforce CRM. The custom contact facet stores the name of the account the contact is associated with.
This walkthrough describes how to:
- Create and deploy a custom contact facet assembly
- Define a collection model
- Deploy and configure the collection model
- Specify how to read from the Salesforce contact
- Specify how to write to the Contact facet
- Map Salesforce data to the contact facet
- Map the contact facet to the contact
- Add new facet to pipelines
Create and deploy a custom contact facet assembly
To store custom data on a contact, you must have contact facets. You implement contact facets in a Micrososft Visual Studio project.
To create and deploy a custom contact facet:
-
In Visual Studio, create the following project:
Project type Class Library (.NET Framework) .NET version .NET Framework 4.6.2 Project name Examples.Connect.Salesforce -
Add references to the following NuGet packages:
-
Sitecore.DataExchange.Tools.SalesforceConnect.NoReferences -
Sitecore.XConnect.NoReferences
NoteSitecore’s public NuGet feed is available at https://nuget.sitecore.com/resources/v3/index.json.
-
-
To create a contact facet to store the Salesforce contact account name, add the following class to the project:
-
To create an xConnect collection model that defines which contact facets are available, add the following class to the project:
-
To deploy the assembly on your Sitecore server, build the Visual Studio project, and copy the resulting
Examples.Connect.Salesforce.dllfile to your Sitecore server.
Define a collection model
A custom data provider exposes the facets defined in the collection model. This makes it easier to configure data mapping that involves xConnect entities by showing the user what is available and reducing the changes that the user enters an invalid value accidentally.
You must register your custom collection model before it can be used.
To define a collection model:
-
In Sitecore, open the Content Editor and navigate to Sitecore/System/Settings/Data Exchange/Providers/xConnect/Collection Models.
-
Add the following item:
Template Collection Model Folder Item name Custom Models -
In the new Custom Models item, add the following item:
Template Compiled Collection Model Item name Custom Collection Model for Salesforce -
Select the new Custom Collection Model for Salesforce item. In the right-hand pane, on the Content tab, in the Settings section, set the following field value:
Field Value Collection Model Type Examples.Connect.Salesforce.SalesforceConnectCollectionModelEx, Examples.Connect.Salesforce -
Save the item.
Deploy and configure the collection model
To deploy the collection model:
-
To deploy the model to xConnect, navigate to the custom collection model. On the ribbon, on the Data Exchange tab, click Convert Model to Items. Then click Convert Model to JSON.

-
Save the model file, and deploy the model to the following servers:
- xConnect collection
- xConnect indexing
-
To configure the xConnect Client Endpoint to use the collection model, in the Content Editor, navigate to Sitecore/System/Data Exchange/
/Endpoints/Providers/xConnect/xConnect Client Endpoint . -
In the right-hand pane, on the Content tab, in the Collection Service section, set the following field value:
Field Value Collection Model Collection Models/Custom Models/Custom Collection Model for Salesforce -
Save the item.
-
To test the configuration, on the ribbon, on the Data Exchange tab, click Run Troubleshooter.

A message informs you a connection to the xConnect collection service was established:

Specify how to read from the Salesforce contact
You must configure the tenant to read the contact data from Salesforce. To do so, you use value accessors and value readers to represent the Salesforce data structure.
To specify how to read from the Salesforce contact:
When it is time to configure the mapping of data from Salesforce to Sitecore, you use the value accessor to specify what value to read from the Salesforce contact.
When you specify that you want to include the account name for the contact, Salesforce returns an account object. This account object has a field that represents the account name. You must create a value accessor to access the name on the account object. This value accessor is never used directly. You must create a value reader that uses the value accessor to read the account name.
To specify how to read from the Salesforce contact:
-
To add the value accessor for the account on the contact, in the Content Editor, navigate to
/Data Access/Value Accessor Sets/Providers/Salesforce/Salesforce Contact Fields . Add the following item:Template Salesforce Object Field Value Accessor Item name Account on Salesforce Contact -
Select the new Account on Salesforce Contact item. In the right-hand pane, on the Content tab, in the Field section, set the following field values:
Field Value Field Name Account Field Name for Select Account.Name -
Save the item.
-
To create the value accessor to access the account name , in the Content Editor, navigate to
/Data Access/Value Accessor Sets/Providers/Salesforce . Add the following item:Template Salesforce Object Value Accessor Set Item Name Salesforce Account Fields -
In the new Salesforce Account Fields item, add the following item:
Template Salesforce Object Field Value Accessor Item name Name on Salesforce Account -
In the new Name on Salesforce Account item, in the right-hand pane, on the Content tab, in the Field section, set the following field value:
Field Value Field name Name -
Save the item.
-
To create the value reader, in the Content Editor, navigate to
/Data Access/Value Readers/Providers/Salesforce . Add the following item:Template Value Accessor Value Reader Item Name Value Reader for Account Name Value Accessor -
In the new Value Reader for Account Name Value Accessor item, in the right-hand pane, on the Content tab, in the Settings section, set the following field value:
Field Value Value Accessor Value Accessor Sets/Providers/Salesforce/Salesforce Account Fields/Name on Salesforce Account -
Save the item.
Specify how to write to the Contact facet
To set up a value accessor set:
-
In the Content Editor, navigate to
/Data Access/Value Accessor Sets/Providers/xConnect . -
Add the following item:
Template xConnect Entity Facet Value Accessor Set Item name xConnect Contact Salesforce Account Information Facet -
In the new xConnect Contact Salesforce Account Information Facet item, add the following item:
Template xConnect Entity Facet Property Value Accessor Item name Account Name on Salesforce Account Information Facet on xConnect Contact -
In the new Account Name on Salesforce Account Information Facet on xConnect Contactitem, in the right-hand pane, on the Content tab, in the Settings section, set the following field value:
Field Value Facet Property Collection Models/Custom Models/Custom Collection Model for Salesforce/Facets/Contact/SalesforceAccount/AccountName -
Save the item.
Map Salesforce data to the contact facet
To map data to the contact facet:
-
In the Content Editor, navigate to
/Value Mapping Sets/Salesforce to xConnect Contact Mappings . -
Add the following item:
Template Value Mapping Set Item name Salesforce Contact to xConnect Contact Salesforce Account Information Facet -
In the new Salesforce Contact to xConnect Contact Salesforce Account Information Facet item, add the following item:
Template Value Mapping Item name Account Name -
In the new Account Name item, in the right-hand pane, on the Content tab, set the following field values:
Section Field Value Source Source Accessor Data Access/Value Accessor Sets/Providers/Salesforce/Salesforce Contact Fields/Account on Salesforce Contact Target Target Accessor Data Access/Value Accessor Sets/Providers/xConnect/xConnect Contact Salesforce Account Information Facet/Account Name on Salesforce Account Information Facet on xConnect Contact Rules Source Value Transformer Value Readers/Providers/Salesforce/Value Reader for Account Name Value Accessor NoteIn the Specify how to read from the Salesforce contact section, you created a value reader for the account name. This value reader is set as the source value transformer on the value mapping. The source value transformer is a value reader that reads a value from the object read by the source value accessor. In this case, the source value accessor reads the account object from the Salesforce contact. However, it uses the account name, not the account object itself. So the source value transformer reads the name from the account object.
-
Save the item.
Map the contact facet to the contact
To map the facet:
-
In the Content Editor, navigate to
/Data Access/Value Accessor Sets/Providers/xConnect/xConnect Contact . -
Add the following item:
Template xConnect Entity Facet Value Accessor Item name Salesforce Account Information Facet on xConnect Contact -
In the new Salesforce Account Information Facet on xConnect Contact item, in the right-hand pane, on the Content tab, in the Settings section, set the following field values:
Field Value Facet Definition Collection Models/Custom Models/Custom Collection Model for Salesforce/Facets/Contact/SalesforceAccount Mapping Set Value Mapping Sets/Salesforce to xConnect Contact Mappings/Salesforce Contact to xConnect Contact Salesforce Account Information Facet -
Save the item.
-
Select your tenant.
-
Navigate to
/Value Mapping Sets/Salesforce to xConnect Contact Mappings/Salesforce Contact to Contact Model . -
Add the following item:
Template Value Mapping Item name Salesforce Account Information Facet -
In the new Salesforce Account Information Facet item, in the right-hand pane, on the Content tab, set the following values:
Section Field Value Source Source Accessor Data Access/Value Accessors/Common/Value Accessor with Raw Value Reader Set Target Target Accessor Data Access/Value Accessor Sets/Providers/xConnect/xConnect Contact/Salesforce Account Information Facet on xConnect Contact -
Save the item.
Add new facet to pipelines
In order for the information in the new facet to be processed, you must add it to the Read Contacts from Salesforce and Process Single Contact from Salesforce pipeline steps.
To add the facet to the pipeline steps:
- To add the fields for the facets to the pipeline step, in the Content Editor, navigate to
/Pipelines/Salesforce Contacts to xConnect Sync Pipelines/Read Contacts from Salesforce Pipeline/Read Contacts from Salesforce . - In the right-hand pane, on the Content tab, in the Object Settings sections, in the Fields to Read field, add Salesforce Account Fields to the Selected column. Save the pipeline step.
- To add the facet to the Process Single Contact from Salesforce pipeline step, in the Content Editor, navigate to
/Pipelines/Salesforce Contacts to xConnect Sync Pipelines/Process Single Contact from Salesforce Pipeline/Resolve Contact Model by Id from xConnect . - In the right-hand pane, on the Content tab, in the xConnect Settings sections, in the Facets to Read field, locate Collection Models/Custom Models/Custom Collection Model for Salesforce/Facets/Contact/SalesforceAccount. Add it to the Selected column.
- Save the pipeline step.