Rabu, 16 Agustus 2017

Salesforce integration in Oracle Integration Cloud Service

In this article, we will show you to create an integration with Salesforce.

Use case description
  • Expose a REST service(Source) that takes five input parameters(first name, last name, designation, employee id and band)
  • Check employee already exist in Salesforce based on employee id. If exists, update employee details else create a new employee
  • Send the response back to REST service caller
Pre-requisites:
  • A REST service connection: Rest service connection should already be created in ICS. If not, please follow the blog
  • Salesforce connection: Salesforce connection should already exist in ICS. If not, please follow the blog
  • Salesforce custom object: Ask Salesforce team to provide the custom object which will be used to send above employee details.
Let's go in deep and see how to use Salesforce custom object to send employee details in ICS.
  • Login into ICS and click on Integration tile from home page
  • Click on Create button from upper right corner
  • Select Orchestration pattern from the dialog box
  • Enter Below information and click on Create button
    • Select Application event or business object radio button
    • Enter Integration Name in What do you want to call your integration text box
    • An Identifier would be picked up automatically from Integration name however you can edit it
    • Keep the Version as it is
    • Enter the description in What does this integration do box
    • Leave the package box as it is
  • Drag the TEST_REST_Conn Connection on the canvas from REST connection
  • Enter below information and Click Next
    • Name of the end point
    • Relative URI(must start with /)
    • Select HTTP verb
    • Select Configure a request payload for this endpoint checkbox- This option allows us to assign sample request payload in the next step
    • Select Configure this endpoint to receive the response checkbox- This option allows us to assign sample response payload in the next step
  • Select Json Sample Radio button: This option allows us to take input in json format. Select inline link to give sample payload 
  • Enter below payload and click OK
{  
   
"employeeId":"ABC@123",
   
"firstName":"Ankur",
   
"lastName":"Jain",
   
"band":"3",
   
"Designation":"Sr. Manager"
}

  • Below step allows us to configure sample response payload. Select JSON radio button and click inline link
  • Enter below payload and click OK
{  
   
"status":"response"
}

  • Click Done button
  • Let's drop TEST_SFDC connection that we created in the blog just below the PostEmployee Map
  • Enter Name in What do you want to call this endpoint text box and leave other option as it is and click Next button
  • Enter below information as below
    • Select SOQL(Salesforce Query Language) from Select an Operation Type drop down. We have selected this option as we would like to enter the Salesforce query to check whether the employee already exist or not
    • Enter below SOQL query. Custom_User__C is the Salesforce custom object which is used to store employee details. Id is the unique id of each record generated by Salesforce on new record inserted. Oracle_HR_ID__C is the field which is used to store employee id.

 select id, ORACLE_HR_ID__c from Custom_User__c where  ORACLE_HR_ID__c='&employeeId'


  • Click Next and Done button
  • Click on GetEmployeeDetails map and click Edit button


  • Map employeeId to employeeId as shown in the below screen shot. Click Validate button and Close button
  • Drop Switch activity from Action tab and drop just below the GetEmployeeDetails connection
  • Click on 1st activity and click Edit button
  • Expand $GetEmployeeDetails -> queryResponse -> QueryResults and drop size parameter to New condition input box. Enter 0 as the value. It means, if the employee will not exist in the Salesforce, value of size will be 0. Click Validate button and Close
  • Drop TEST_SFDC connection from Invoke tab as shown in the below screen shot
  • Enter Name in What do you want to call this endpoint text box and leave other option as it is and click Next button
  • Enter below information and click Next button
    • Select CRUD, create option from Select an Operation Type drop down
    • Search Custom_User__C object and Move to the right pane

  • Click Next and Done button
  • Click CreateEmployee map and edit button
  • Map source and target fields as shown below
  • Drag & Drop TEST_SFDC connection from Invoke panel as shown below
  • Enter Name in What do you want to call this endpoint text box and leave other option as it is and click Next button
  • Enter below information and click Next button
    • Select CRUDupdate option from Select an Operation Type drop down
    • Search Custom_User__C object and Move to the right pane
  • Click Next and Done button
  • Click UpdateEmployee map and edit button
  • Map source and target fields as shown below


  • Drop an Assign activity just below the PostEmployee connection and create a variable named employeeStatus. This variable will be used to set the employee status(created or updated)

  • Again, drop an Assign activity in if  block and select the same variable employeeStatus that we created in the previous step and assign the value created as shown in the screen shot
  • Again, drop an Assign activity in Otherwise block and select the same variable employeeStatus that we created in the previous step and assign the value updated as shown in the screen shot
  • Drop a Map activity just above the PostEmployee response
  • Edit the mapper and map employeeStatus to status
  • This is the last step to complete our integration. Let's add a tracking field as we always do in all the integration to track the Integration instance.
  • Click on Action menu and select Tracking option
  • Drag employeeId to the right panel and click Done button
  • This completes our integration and it looks like below
  • Let's activate the integration and test it using POSTMAN tool. If you don't' know how to activate the integration then please see Activate Integration step in the blog
  • Let's test it using POSTMAN tool
    • Open POSTMAN tool
    • Enter Service end point
    • Add Basic Auth as ICS service is by default secured. We need to provide ICS console credentials.
    • Enter payload and hit Submit button

See the response, it say's created. It means a new employee has been successfully created.
  • Let's hit the same request again and see the response

See the response, it say's updated. It means already existing employee has been updated.





Tidak ada komentar:

Posting Komentar