Create Salesforce Leads Using the Sitecore xConnect Module

September 23rd, 2019

As you know Sitecore has a Salesforce Sales cloud connector module (Sitcore xConnect), using which you can create Salesforce contacts which can be managed from Sitecore user manager (Salesforce domain). There is this PDF file that describes on the installation steps. 

I faced one major challenge with this. The default token request url used is "". This is the production environment url and what I had was the Salesforce staging environment access. If you check the PDF file used for installation, there were no such settings to specify the staging token request url ("").

I was able to find this github link "" to download the source code for Salesforce connector. This might be an older version of connector code but I still wanted to try. I got this code, and noticed there is indeed a config file where I could not only enter "consumerKey", "consumerSecret", "userName", "Password", "securityToken" (all of these that I earlier entered into Sitecore fields as mentioned in the PDF file), but now also "tokenRequestUri". So in this "tokenRequestUri" I now specified the Salesforce Staging token url of "". 

        <client provider="salesforce" type="Sitecore.Salesforce.Client.SalesforceClient, Sitecore.Salesforce.Client" singleInstance="true">  
          <param desc="authenticator" type="Sitecore.Salesforce.Client.Security.PasswordAuthenticator, Sitecore.Salesforce.Client">  
            <consumerKey>\[consumer key\]</consumerKey>  
            <consumerSecret>\[consumer secret\]</consumerSecret>  
            <userName>\[user name\]</userName>  
            <securityToken>\[security token\]</securityToken>  

I was now able to view and create Salesforce Sales cloud "Contacts", that I was able to verify on Salesforce cloud staging environment (""). My ultimate target was to create Salesforce Sales cloud "Leads" but did not find any such functionality in the code. So, I added my onel custom code for the same.

Please find attached the DLLs (SitecoreSalesforce, SitecoreSalesforceClient) for this latest updated Salesforce connector with my code to create Salesforce "Leads". 

So, here are the steps:

1- Copy the config file "Sitecore.Salesforce.Config" into "...\App_Config\Sitecore\SalesforceConnect". Add parameters under [<client provider="salesforce"] as shown above.

2- You copy the dlls "Sitecore.Salesforce.dll" and "Sitecore.Salesforce.Client.dll" into your Sitecore solution bin folder.

3- Add reference to these dlls in your Sitecore project, you can create a form to accept the Lead parameters and then create an object of my custom class "Leads" as follows:

       public bool CreateLead(string firstName, string lastName, string email, string phone, string company)  
            Leads salesforceLead = new Leads();  
            OperationResult result = salesforceLead.Create(firstName, lastName, phone, email, company);  
            return result.Success;  

You can verify if the Lead is created right by visiting the Salesforce Sales cloud site (in my case "") and the Leads section.