Salesforce CRM Graph Templates

This collection of graphs allows Kitewheel to integrate with Salesforce CRM  and allows the reading and creation of records - examples are given for contacts and can be easily extended to other object types. This uses the Salesforce REST API

Prior to each call to Salesforce the access token is checked for validity - it is expected that this token will expire every two hours (Salesforce default setting) and will refresh if necessary. The token is saved and shared using the application parameters custom graph template.  

The schema names follow the Salesforce naming conventions and so are typically not camel case. 

Package contents

  • Connections
    • sfOAuthToken - REST web service -  used to refresh the OAuthToken 
    • sfQuery -  REST web service - used to query the Salesforce instance
    • sfObject - REST web service - used to create, update, delete and read all Salesforce object types (Lead, Account, Contact etc)
  • Graphs: 
    • sfRefreshToken  - ensure that the Salesforce access token is up to date
    • sfFindContactByName - find a contact by first name and last name 
    • sfContactCreate - create a new contact from the Salesforce → Contact schema location
    • sfContactRead - reads a contact 
      • Uses the id field in the sfContact schema location 
      • Overwrites existing field values in the sfContact schema location 
    • sfLeadCreate - create a lead from the Salesforce → Lead schema location
    • sfTestContactCreate - a sample graph that searches for a contact before creating it 
    • sfTestLeadCreate - a sample graph that creates a new lead and returns the Id 
  • Public Variables: 
    • sfAccessToken - transaction 
    • sfCreds - transaction used to get Access Token 
    • sfSearchResults - transaction - used to hold search results for processing 
    • sfResponse - used to get the intermediate response from the web service - identifiers are returned as lowercase "id" and the objects expect them as "Id" 
    • ignore - transaction - used for results from nodes that should be ingnored
    • temp - transaction - used for temporary values 
  • Schema
    • sfAccessToken - used to hold the access token for web service requests
{
	"sfAccessToken": {
		"issued_at": "",
		"access_token": ""
	}
}
  • sfContact - hold the fields for a Salesforce contact - can be extended with custom fields

    {
    	"sfContact": {
    		"Id": "1232563253",
    		"Email": "nskilling@kitewheel.com",
    		"LastName": "Skilling",
    		"FirstName": "Kitewheel",
    		"Salutation": "Dr"
    	}
    }
  • sfLead - hold the fields for a Salesforce lead - may need to be extended with custom mandatory fields

    {
    	"sfLead": {
    		"Id": "",
    		"Email": "neil@madeup.com",
    		"Phone": "+123456789",
    		"Title": "Mr",
    		"Status": "New",
    		"Company": "BC Corp",
    		"LastName": "Skilling",
    		"FirstName": "Neil $$",
    		"LeadSource": "Website",
    		"MobilePhone": "+76767676878"
    	}
    }

Setup 

  • Create a REST Webservice connection with the following details:
    • The part in the red rectange needs to be replaced with your own instance of Salesforce. 
    • Additonally, depending on the endpoint the part of the endpoing after '/v40.0/' may be different.
      • For sfQuery it should look as shown in the picture above
      • For sfObject is should be ended with 'sobjects' instead of 'query'
      • For sfGetResources it should just end after '/v40.0'
    • The sfOAuthToken endpoint should look as follows and will be the same no matter your Salesforce instance. 
  • In Salesforce create an application and generate the Client Id and Client Secret 
    • In the standard layout of Salesforce, on the Apps page, there is a button to create a new Connected App (note: this may look different if you are using the lighting view of Salesforce)
    • When creating a connected app, only the required feilds are needed. For the 'Selected OAuth Scopes' only 'Access and manage your data (api)' and 'Perform requests on your behalf at any time (refresh_token, offline_access)' are needed. The first to create and manage leads, contacts, activities, etc. and the second to refresh the token in order to stay connected to Salesforce. 
  • Follow the instructions for the setup of the application parameters custom graph template
  • Create application parameter values in the application parameter table with the following paramKeys: 
    • sfClientId
    • sfClientSecret
    • sfUserName

    • sfPassword - the concatenation of the password and the security access token 
  • Sample SQL Insert statements: 
INSERT INTO appParams(paramKey,paramValue,paramType,description) VALUES
('sfClientId', 'YOURCLIENTID','string', 'Salesforce Client ID'), 
('sfClientSecret', 'YOURCLIENTSECRET','string', 'Salesforce Client Secret'), 
('sfUserName', 'USERNAME','string', 'Salesforce User name'), 
('sfPassword', 'PASSWORD','string', 'Salesforce Password concatenation of password and security token'),
('sfAccessToken', '','string', 'Salesforce Access Token - automatically updated do not fill in yourself'),
('sfTokenIssuedAt', '','string', 'Salesforce token issue time - automatically updated do not fill in yourself');

Using

  • sfFindContactByName - find a contact by first name and last name 
    • Expects the FirstName and LastName values in the sfContact schema location 
    • Returns the Salesforce ID under the sfContact schema location
  • sfContactCreate - create a new contact 
      • Uses the fields in the sfContact schema location to create a new contact 
      • The id will be updated to be the Id of the new contact if successful
      • Returns false if the contact fails to create 
      • Your organisation may have mandatory custom fields that could cause the creation to fail - extend the sfContact schema to add these fields and ensure that they are populated before the call to the sfContcatCreate graph. For example at Kitewheel we have a custom field 'Status' which is stored in Salesforce as 'Status__c'  (all custom field names end with __c) which must be set: 
  • sfTaskCreate - create a new task
    • This can be modified to create things besides a task such as an activity
    • Tasks or other events have required fields that need to be passed to it or it will fail. If these fields have default values they will be set to the default value if none is given
    • Tasks requires a 'Subject' field. Other required fields have default values ('Assigned To' for example defaults to the user creating it)
  • sfLeadCreate
    • This is a slight modification of the sfContactCreate graph and the instructions are the same.
  • Any other kinds of inserts or reads that can be done in Salesforce are easy to create using the REST Webservice Adaptor, simply follow the Salesforce documentation for any additional requirements for different endpoints


Privacy Policy
© 2022 CSG International, Inc.