Introduction:

In this blog post, I will explain how to use Salesforce Adapter in Cloud Integration for a case replication scenario.

Scenario:

  1. External system will send details related to the logged ticket in JSON format. This is mimicked using Postman. The message will contain requester’s email, account no of the organisation and other details related to the raised ticket.
  2. Cloud Integration flow will receive the details and send it to Salesforce either to create a new case or update an existing case. Ticket no. will be used as an External ID in Salesforce for the ‘upsert’ function.
  3. The response will be sent back to the calling system. In my case, Postman.

Prerequisite Setup:

  1. Set up Integration Suite trial. This is necessary to create Integration flow in Cloud Integration. Help Link: Setup.   
  2. Download and install Salesforce Adapter in Cloud Integration. Help Link: Salesforce Adapter. Go to Integration Package in CI -> Artifacts tab -> Add -> Integration Adapter. After successful deployment, it will show up in the Overview/Manage Integration Content, shown as below.                         Salesforce%20Adapter%20Deployment
  3. Create a trial account in Salesforce (https://developer.salesforce.com)

Setup in Salesforce:

  1. After creating a trial account in Salesforce, go to Settings -> Reset My Security Token. It will send a new token to the registered email. I will use this token in Cloud Integration flow later along with my login credentials for Salesforce connectivity.

Reset%20Security%20Token%20in%20Salesforce

Reset Security Token in Salesforce

   2. Create a Connected App in Salesforce. It will create a Consumer Key and a Secret.                          Connected%20App%20in%20Salesforce

Connected App in Salesforce

    Help Link: Connected App in Salesforce

3. Create a custom field in Salesforce for Case object which will be used as External ID.

       Custom%20Field%20in%20Salesforce

Custom Field in Salesforce

   Help Link: Custom field in Salesforce

 

Design Solution in Cloud Integration:

 

Integration%20Flow

Integration Flow

 

Step 1:

Configure sender channel as below.

HTTPS%20Sender%20Channel

HTTPS Sender Channel

Step 2:

Call Local Integration Process via Process Call.

Step 2.a:

Convert JSON message to XML.

JSON%20to%20XML%20Converter

JSON to XML Converter

 

Step 2.b:       

Set below properties in Content Modifier.

AccountNo will be used to get the Account ID in the next step.

queryId from Input message will be used as External ID.

Content%20Modifier

Content Modifier

Step 2.c:

Use Request Reply step to fetch Account ID using account number.

Receiver%20Salesforce%20Adapter%20Connection%20tab

Receiver Salesforce Adapter Connection tab

  • Basic Credential: Create User Credential in Manage Security Material. Login credentials will be used as user and password.
  • Security Token Alias: Create Secure Parameter in Manage Security Material to save Salesforce security token.
  • OAuth Credential: Create User Credential in Manage Security Material. Consumer key and consumer secret will be used as user and password, respectively.

Receiver%20Salesforce%20Adapter%20Processing%20tab

Receiver Salesforce Adapter Processing tab

Step 2.d:

Configure the Content Modifier step as shown below.

Content%20Modifier%20Exchange%20Property

Content Modifier Exchange Property

Content%20Modifier%20Message%20Body

Content Modifier Message Body

Step 2.e:

Use Message Mapping to map the input fields to desired sObject XSD structure. The XSD structure for sObject can be downloaded from Eclipse plugin – Salesforce Adapter Workbench.

XSD%20Generator

XSD Generator

Message%20Mapping

Message Mapping

Use Groovy Script to get value of property AccountId.

Groovy%20Script

Groovy Script

Step 2.f:

Use Request Reply step to send data to Salesforce.

Receiver%20Salesforce%20Adapter

Receiver Salesforce Adapter

Step 2.g:

Convert received XML payload back to JSON.

Test Execution:

Test Case 1: Create a new case in Salesforce

Trigger message using Postman tool to the cloud integration flow endpoint.

Postman%20Request/Response

Postman Request/Response

The record is created in Salesforce.

New%20Case%20in%20Salesforce

New Case in Salesforce

Test Case 2: Update the case in Salesforce

Postman%20request/Reply

Postman request/Reply

The record is updated in Salesforce.

Updated%20Case%20in%20Salesforce

Updated Case in Salesforce

Please note the data used in executing these scenarios is test data/ fake data only.

Behind the Scene:

While configuring the salesforce adapter, only the generic login URL of Salesforce is used. The actual execution happens in two steps. Both of these steps are handled by adapter level internally.

Step1: A call is made to https://login.salesforce.com/services/oauth2/token into Salesforce using login credentials, security token and client credentials. In response, salesforce returns an access token and instance URL.

Step 2: The next call is made to the instance URL along with a specific path (based on sObject) using the access token. That’s it!

Thank you for reading this blog post. Please feel free to share your feedback or thoughts or ask questions in the Q&A tag below.

Randa Khaled

Randa Khaled

Author Since: November 19, 2020

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x