To create truly personalized experience, marketers need rich and up-to-date data. Using Sitecore Connect for Salesforce CRM, data will be synchronzed between Salesforce CRM and Sitecore Experience Platform. This article is a step by step guide how to set up the connector.

Step one: Install the necessary packages

You’ll need to install a collection of packages to be able to sync between Sitecore and Salesforce.

In this example, we used Sitecore 9.0.2 to install the following packages in the same order:

 

Serialize and deploy to xConnect Collection model:

Once you finish installing the above-mentioned packages, Sitecore will create new custom facets. These facets will be used to associate information from Salesforce with Sitecore contacts and interactions.

These facets are not defined yet to xConnect. So, we’ll need to deploy the collection model of these facets to make them defined for xConnect.

  1. Go to Sitecore instance.

  2. Open the Content Editor and navigate into “sitecore/system/Settings/Data Exchange/Providers/xConnect/ Collection Models/Connect for Salesforce/Connect for Salesforce Collection Model”.

  3. Click the “Convert Model to JSON” from the ribbon.

  4. The Salesforce Connect Collection Model contains the following facets: SalesforceContact, SalesforceCampaignMembership and SalesforceInteraction.

  5. To deploy the new collection model, copy the JSON file into the following paths on the
    1. xConnect server
      1. [PATH TO XCONNECT]\App_Data\Models\
    2. xConnect Search Indexer. By default, this one is located on the same path to the xConnect server and under:
      1. [PATH TO XCONNECT]\App_Data\jobs\continuous\IndexWorker\App_Data \Models\

Configure Salesforce

Now, we’ll need to do some configuration on Salesforce side. If you don’t have a Salesforce account and would like to test the connection, Salesforce offers you a developer account (free account) (https://developer.salesforce.com/signup).

When you log into your Salesforce account for the first time, the default interface of the CRM is called “Lighting Experience” which is more modern and faster. As I noticed, the Sitecore documentation for Salesforce connector is based on the classic Salesforce interface.

 

To switch from the “Lighting Experience” into Salesforce Classic:

  • Click on the profile image icon on the top left corner and then click on Switch to Salesforce Classic
  • The Salesforce classic interface looks like this

To be able to connect Salesforce with Sitecore, you’ll need to create a custom app on Salesforce:

  1. Click on “Setup” from the top menu



  2. Click on “Apps” from the left side menu



  3. You’ll be redirected to the “Apps” page. There is a section for “Connected Apps”, click “New” to create a new connected app.


  4. Fill in the necessary/Required information to complete creating the new app as mentioned below


  5. We’ll start by filling in the basic information



  6. Enable the OAuth Setting



  7. Click on Save

  8. You’ll be redirected a new page with a message telling you that the app was successfully created. Click on Continue

  9. Notice now that the new app is added under the section “Connected Apps


Add custom fields in Salesforce

If you would like to write contact data from Sitecore to Salesforce, you will need to create a custom field in Salesforce and associate this field with the corresponding on Sitecore.

  • Create the custom Salesforce Contact field
  1. From the left side menu, navigate into Build > Customize > Contacts > Fields



  2. You’ll be redirected into the Contact fields page


  3. Go to “Contact Custom fields & Relationships” section and click on “New



  4. Follow these steps:

    1. Choose the field type: TEXT, then click on “Next



    2. Enter field details, then click on “Next



    3. The two last steps are about specifying the security level of the field and on which page layouts it can be displayed in Salesforce.

    4. Finally click on “Save

    5. The new field is created. (Salesforce adds “__c” at the end of a custom field name to show that the field is a custom field)

  • Create the custom Salesforce Activity field
  1. From the left side menu, navigate into Build > Customize > Activities > Activity Custom Fields



  2. Click on “New


  3. Follow the same steps mentioned to create a custom field on contact object with the same entered values.

  4. When you finish, you will get the new field under Activity Custom Fields page


 

Configure the connection string

We have installed the necessary packages needed on our Sitecore instance to connect to Salesforce and on Salesforce we created the custom app that will be used to synchronize data between both systems. We still need to configure the connection string in our Sitecore project and specify the endpoints.

The connection string will look like this:

<add name="[name of the connection]" connectionString="user id=[user id];password=[password];client id=[client id];secret key=[secret key];security token=[security token]" />

  • [name of the connection]: you can replace this with any name you want.
  • [user id]: is the ID of Salesforce user that Sitecore uses to connect to the Salesforce API
  • [password]: the password of this Salesforce user
  • [client id]: the customer secret value in Salesforce connected app
  • [security key]: the consumer key value in Salesforce connected app

NOTE: it is important to define from the beginning the Salesforce account that will be used to establish the connection between both systems. The level of user permissions/rights depends of the purpose of this connection.

For example, of you only need to read contact data from Salesforce and create the corresponding data in Sitecore, it is enough to have read-access on both contacts and campaigns. But if you want to push the contact data from Sitecore into Salesforce, then you will need to have write-access on contacts in Salesforce.

 

Get the Client ID and the Secret Key

  1. Navigate into Build > Create > Apps > Sitecore Data Exchange App (the connected app we just created)

  2. Click on the Sitecore Data Exchange App

  3. You will get a detail page about the app

  4. Copy the “Consumer Key“ value to replace the “Client ID” in the connection string and the “Consumer Secret” value to replace the “Secret Key” value in the same connection string.

 

Get the Security Token

  1. From the top menu, click on your username. A drop menu will get displayed, click on “My Settings"



  2. On the left menu of the page, navigate into My Settings > Personal > Reset My Security Token



  3. Click on the “Reset Security Token” button.



  4. A notification will be displayed telling you that the new security token is sent to your email.



  5. Open your email inbox and get the access token.

  6. Add it to the connection string.

 

Finally, a connection string for Salesforce will look like this example:

<add name="mysf" connectionString="user id=someone@email.com;password=b;client id=GEH9zlTNB8o8BA45pAeDtC8W.DIqrAzuky2uffEEOwtHxIEhLzkmPwjz8KF_vzWY8dNIfurWHpfb ZPGdtc3b;secret key=5468568999798354123;security token=g3ygFuNzGgm33YTfsM3WKG3AA" />

Now, you can go to Sitecore Connection string in your project root > App_Config > ConnectionStrings.config to add the Salesforce connection string after collecting the necessary data from Salesforce.


Time to Sync Data between both systems 😊

Create a tenant

  1. Navigate in Sitecore into System > Data Exchange

  2. Click on “Connect for Salesforce Tenant” to create the tenant. This tenant will contain our configuration and endpoints to connect both systems and sync data.



  3. Give a meaningful name to the tenant



  4. It is possible to create multiple tenants on the same solution to connect to different Salesforce instances or under the same tenant. In this example, we’ll establish one connection to one instance.

  5. Click on “OK”, the script of creating the tenant will get executed. This could take some time to create the tenant and its componets.



  6. Once the tenant is successfully created, navigate into Endpoints > Providers > Salesforce > Salesforce Client Endpoint

  7. Add the name of the connection string we have added to the ConnectionStrings.config (mysf) to “Connection String Name”. Sitecore will get the connection string parameters from the config file to connect to the Salesforce API.



  8. Test the connection to Salesforce by clicking on “Run Troubleshooter” on the ribbon



  9. If you see the above pop-up window, then the connection was tested successfully.

  10. Now we need to do the same for the xConnect endpoint. Navigate into Endpoints > xConnect > xConnect Client Endpoint, and make sure to add the same values in the image below. (you can find these connection string names on your ConnectionStrings.config) (these names are the default names to connect to xConnect, if you changed the names make sure to update the Endpoint as well).



  11. Test the connection to xConnect.



  12. By default, the tenant is not enabled to execute the process of synchronization between Sitecore and third-party systems. In a later stage, we’ll enable the tenant and execute the process.

 

Update a Salesforce custom field

  1. Let’s check if in the default configuration, the custom field we added on Salesforce matches the one mentioned in the tenant



  2. Navigate into Data Access > Value Access Sets > Providers > Salesforce



  3. Open the “Salesforce Contact Fields” and click on “Sitecore Id on Salesforce Contact

  4. The default value of the field does not match, here, the one we added on Salesforce contact.



  5. Update the value with “Sitecore_Id__c” (the API Name of the Salesforce field), then save your changes.

 

Push contact data from Sitecore to Salesforce

  1. We have created a testing contact on the List manager to test pushing data into Salesforce. Notice the email address of the testing contact (this contact does not exist or created in Salesforce)



  2. Sitecore DEF has the idea of Pipelines and Pipeline batches. Pipelines items contains a set of Pipeline Steps and Pipeline batches can include one or more pipelines to execute.

  3. Before you execute the batch, you’ll need to make sure that the tenant is enabled.



  4. Ok, our testing contact is created in XDB



  5. To push the contact into Slaesforce, we’ll need to run a batch. Navigate into Pipeline Batches > xConnect Contacts to Salesforce Sync, click on “Run Pipeline Batch



  6. Go to Sitecore, find the Contacts List (normally, in the classic interface, you can click on the “+” button and select “Contacts”, then Go to All Contacts)



  7. As you notice the Sitecore contact is added to Salesforce Contacts List with the same email address


 

Write Contact data from Salesforce into Sitecore xConnect

  1. As you noticed, the XDB only contains the contact we have created. Now, we’ll add the Salesforce contacts into Sitecore XDB via xConnect.

  2. If you have a look on the Salesforce Contacts List in Salesforce, you’ll see that Salesforce creates about 20 testing contact for you (Developer Account).

  3. To add these contacts into Sitecore, navigate into Pipeline Batches > Salesforce Contacts to xConnect Sync. Running this batch will make Sitecore reading the Contacts from Salesforce and add them to Sitecore XDB.



  4. If you go now to the database of ContactFacets, you’ll find that these contacts were added there!

 

We hope this blog was useful for you and answers on your questions about the synchronization between Sitecore and Salesforce.

For more information, our certified and experienced Sitecore team will be happy to help. Just contact us here and we’ll respond asap!

X

Our site uses cookies to improve the website experience. By using our website, you agree to our use of cookies. Click here for more information.

Accept and continue