Salesforce Integration with SAP IRPA 2.0 to insert data records using API calls
We are in an age where customer experience plays a prominent role in making decisions for overhauling products and innovation in an organization. The prime factor methods can be applied to make a strategic plan and to free up user’s manual tasks. An organization needs an end-to-end automation process to update various customer data into a CRM system. With the help of SAP intelligent robotic process automation 2.0, a business user can automate their daily activities and proactively get in touch with the customers.
In this blog post, we are going to see, how integration of SAP Intelligent RPA with Salesforce Organization, is possible using API calls. We are also going to write/post data records into Salesforce. API stands for Application Programming Interface. Salesforce APIs are a way for other applications to programmatically access data, within your Salesforce org, in a simple and secure manner.
We are going to be using REST APIs to interact with salesforce system. For this to be possible, we need to enable the REST API access on the Salesforce side. Salesforce provides Connected App to connect with the platform of any other application.
Steps to create a connected app in salesforce:
In Salesforce, navigate to Setup =>Platform Tools=>Apps=>App Manager. Click on New connected app.Enter the required information.Select Enable OAuth settings.Enter the call back URL and choose ‘Full Access’ in Selected OAuth Scopes. Click on save and continue.
Go back to your App manager, choose your connected app and click on view. Make note of the consumer key and consumer secret. To get the consumer key, click on reveal.Now we have the API access enabled at the Salesforce end. Let us go ahead with creating the automation bot.
First step would be to login to SAP Intelligent RPA Cloud factory, go to projects tab and create a new project.Enter the project name and description and click on create. This will create a project and the project is opened in a new window.Under Content tab, click on create and select Automation.Provide the name of the automation and description in the pop-up window and click on create. This will create an automation with an empty workflow.
A custom script is added to the workflow as the first step in the workflow, to set up a secure connection to Salesforce.
For us to establish a secure connection to Salesforce, we need to get the Authentication. Authentication is used for getting access token and instance URL. To get those details, we need to set up a login request URL.
In the login URL, client_id, client_secret, grant_type, user id and password must be entered in the format shown below.
‘https://[Domain].salesforce.com/services/oauth2/token?grant_type=password&client_id=[Your consumer key]&client_secret=[Your consumer secret]&username=[salesforce Username]&password=[Salesforce Password]’
Click on Edit script and custom editor window opens. Add the below code to fetch the access token from Salesforce.Method type used is ‘POST’. ‘irpa_core.request.call() is used to make the API call. Response of the API call will have the access token, instance URL, and token type details. Token type and Access token are concatenated and stored in a separate variable. Access token details are returned to the workflow by creating output parameter in the custom script.
Log message activity is added to display the Token details.Add another custom script to insert data records into Salesforce. Input parameters are created to pass instance URL, Access token and Object to which the data records are to be inserted, to the custom script from the workflow.Custom script contains the below shown code.Request URL will be in the format ‘[instance URL]/services/data/[Salesforce Version]/sobjects/[sObjectName]’. In our case, we are inserting data records into sObject ‘Account’.
Method type will be ‘POST’, as we are writing the data into salesforce. Headers parameter contains the content type and authorization parameters. Access token fetched from the first step is passed as Authorization parameter. Body of the request contains the data values that must be inserted. The complete request options parameter ‘addOpt’ is returned to the workflow by adding output parameter named ‘Options’ in the custom script.
Call web service activity is added next, to call the API service. Returned value ‘Options’ from the previous step is passed as the input parameter to Call web service activity.Output parameter ‘obj’ is returned as the response of the API call.
Log message activity is added as the next step to display the response of the API call.
Below is the screenshot of the complete workflow.‘sObject’ is added as the input parameter for the user to enter the sObject name.
Below is the screenshot of the user Input window that pops up when the bot is run.Below is the output of log message activity which displays the Access token and Instance URL.Output of the log message activity that displays the response of the data insertion API call is as shown below.Success message here indicates that the data record has been successfully created in the Salesforce account.
Below screenshot shows the newly created data record in Salesforce.Here is the project demo video.
Seamless integration to different systems is possible with simple steps using SAP Intelligent RPA features.
The intention of this blog post is to get customers, business managers and RPA developers to get into thinking about using SAP Intelligent RPA 2.0 in numerous automation scenarios by using simple steps for achieving great results.
I hope you found this tutorial helpful. Please provide feedback in the comment section and feel free to ask any questions in the SAP Intelligent RPA Q&A area (link for reference: https://answers.sap.com/tags/73554900100800002142)