Display Account data from another Salesforce org using a Flex card
Introduction
As a part of this article, we are gonna build a simple example by utilizing Integration procedures and Flex cards to display the list of Account records retrieved from another Salesforce org.
Before we can start building experiences with Omnistudio and get started, we need to get a free Developer Edition with OmniStudio.
Once our org is ready, we can access OmniStudio from application launcher (9-dots) in Salesforce.Also, to get a basic idea about OmniStudio architecture and why do we need OmniStudio , refer this link :
Now that we are inside Omnistudio, let’s first get started with building an Integration procedure. Now, for those of you, who are not aware about what an Integration procedure is , more details are available here:
But for now, for the basic understanding ,Integration Procedures are declarative, server-side processes that execute multiple actions in a single server call.
As shown below, since we are gonna get the data from another Salesforce org , we need to first take care of few pre-requisites:
- Setting up the connected app in the destination org.
- Adding the instance url of destination org in the remote site settings in the Source org.
Once that’s done , we can get started with our Integration procedure that’ll get the data from another Salesforce org using the stndard rest api.
1.We are utilsing a HTTP Action for the same, so in order to get the data, we first need to authenticate the other org and get the access token. So, the action GetTokenFromOtherSalesforceOrg takes care of it. In the HTTP Path add the url to get the access token(with your org instance url) and then in Params add all the details required to authenticate inclusing grant_type , client, client secret etc. as shown below. We are using Username Password authentication flow for this example. The flow can be tested by going to Preview tab and clicking the Execute button at the bottom, the Debug output for the action will be available on the right hand side.If everything goes well, we’ll get the access token.
2. Once we have the access token, we can choose to either store it in a variable or access it directly it in the other HTTP Action to get the account records.As shown below we are now using a SetValues Action from left hand side to store Access token that we got from theprevious action .One thing to note here is :
%GetTokenFromOtherSalesforceOrg:access_token% is the merge field syntax to get the access_token attribute from the response of the previous HTTP action.
3. Next, we are using another HTTP Action to get the Account records using query rest api as shown below. We are accessing the access token using the following merge syntax %SetAccessToken:AccessToken%.
4. Once this is successful, we can check the output from the Debug output that’s available in the Preview tab.Now once we verify the output and we have the first 10 Account records, We’ll now use Response Action action to store the response The account records are available under records attribute in json as shown below. So we are sending GetAccountDataFromOtherSalesforceOrg:records in the Send Json Path.
Response Action passes data back to the tool that launched the procedure
5. Our Integration Procedure is now ready, we can activate it and can get started with the Flex card.More information on Flex card is available here:
For the basic understanding, FlexCards summarize basic information at a glance
Create a new flex card, A flex card needs a data source in order to show the information, In our case the data source would be an Integration Procedure.So, in the next step choose the Integration Procedure that we have created above.
Once we have selected the integration procedure, we can verify whether it’s returning the data by clicking on the Fetch button as shown below .Once we verify the data, we can move ahead and click on the save button.
6. Drag and drop field element to display information like Account name, phone and website in the Flex card as shown below:
7. Once done, click on Preview button, to check how our flex card looks like as shown below. We can also add the block element in our Flex card and make it responsive and then add field elements to it.So, one thing to note here is that we have a flex card for each record in the array.This is because we have Repeat Records enabled by default under Setup Panel in the flex card.
That’s it now, We were able to get the account records from another Salesforce org using an Integration Procedure and then display those records in the Flex card.
For the next time, we’ll also add few actions to the flex card and launch the Omniscript from the Flex card.
Do comment in case of any questions. Stay Tuned!!