Combine Internal Data for FlexCards
Learning Objectives
After completing this unit, you’ll be able to:
- Describe the data sources for FlexCards.
- Describe JSON nodes and subnodes.
- Build with multiple nodes in the JSON output.
Data Sources for FlexCards
For the most part, FlexCards work with OmniStudio data tools in the same way that OmniScripts do. Remember—it’s possible to connect the same Integration Procedure or Data Mapper to more than one OmniStudio component. In this unit, we show how these OmniStudio data tools combine data for more than one FlexCard.
Here’s an Account FlexCard that displays the Account’s name, Primary Contact, Phone number, Website, and Postal Code.
And here’s a Contact FlexCard that displays the Account’s Contacts, including their names, email addresses, and phone numbers.
How do you retrieve data for both of these FlexCards using a single Integration Procedure? Let’s start by examining the data sources available for FlexCards. There are several data input options for a FlexCard. When it comes to inputting data, Integration Procedures are a best practice because Integration Procedures separate the data configuration from the FlexCard configuration. You can learn more about this in the OmniStudio Integration Procedures module.
However, there are a few scenarios where using an Integration Procedure is not recommended.
Data Source |
When to Use This Data Source |
---|---|
Streaming API |
For automatic updates when data changes |
Salesforce Object Search Language (SOSL) |
For text field searches across Salesforce objects |
Sample |
For display or testing of static data |
When an account-based FlexCard displays on a console, the Account RecordId passes to the FlexCard on a variable called {recordId}. You pass this to an Integration Procedure via a variable named AccountId. All of these variable names are arbitrary but must match for the data to flow correctly.
The Integration Procedure passes the AccountId to a Data Mapper Extract. The Data Mapper Extract then uses the AccountId to identify a unique Salesforce record, and through a series of Salesforce Object Query Language (SOQL) queries, requests data from Salesforce. These queries return the AccountId and other fields from the Account record and other fields from associated Contact records.
The Data Mapper maps and returns the data to the Integration Procedure, which then passes it back to the FlexCard. This JSON populates the FlexCard and any child FlexCards with the data that end users see on the console.
What Are JSON Nodes and Subnodes?
Data in a JSON is divided into nodes and, sometimes, subnodes.
The JSON data below has two nodes: Account data (1) and Contact data (2). Each node is set off by a colon : and a curly bracket { }. Additionally, the Contact node has two subnodes—one for each Contact (3). Each of these is set off by a curly bracket.
The JSON structure that best supports use on multiple FlexCards uses parent nodes for each FlexCard. Filtering the Result JSON Path trims the data and pulls only relevant data to the FlexCard.
Build with Multiple Nodes in JSON Output
Now that we’ve walked through FlexCard data sources and JSON nodes and subnodes, let’s start with the Data Mapper Extract we need to build with multiple nodes.
The order of extract steps in a Data Mapper is important to refer to data from another step. In this Data Mapper’s Extract tab, you need to execute the following steps.
- Retrieve the account data.
- Retrieve contact data related to the account.
- Filter using a particular field in the account (the Primary Contact field). In a Data Mapper, you can use filter criteria from an object used in an earlier Extract step.
In the Output tab, create the mappings between the extract step JSON to the output JSON for both the Account and Contact objects.
To create a subnode, use a colon when mapping the Output JSON Path. For example, Account:AccountName and Account:AccountWebsite creates an Account node that lists the AccountName and AccountWebsite fields.
Now let’s take a look at how you configure the Integration Procedure.
When you create an Integration Procedure, add a Data Mapper Extract Action (1) to the Structure panel. Use the Data Mapper Interface field (2) to connect the Integration Procedure and the Data Mapper.
Set the Integration Procedure as the data source for the Account and Contacts FlexCards, and now you have a single Integration Procedure that retrieves data for both the Account and Contacts FlexCards. Way to go!
You’re now familiar with how OmniStudio data tools handle internal data. To learn how these tools work with data from external sources, head to the OmniStudio Data Tools and External Data module.
Resources
-
Trailhead: OmniStudio FlexCards
-
Trailhead: OmniStudio Data Mappers
-
Trailhead: OmniStudio Integration Procedures
-
Trailhead: OmniStudio Data Tools and External Data