OmniStudio DataRaptors — Extract
- August 18, 2022
In this blog we are going to start with the Service Management layer in OmniStudio and cover Extract DataRaptor in detail.
Omnistudio has three layers:
- Digital Experience is more of a UI layer and contains components like FlexCards and OmniScripts
- Service Management focuses on the back-end processing though DataRaptors and Integration Procedures
- Developer Experience comes into the picture once development is complete and focuses on deployment
DataRaptors are a part of the Service Management layer of OmniStudio. They’re basically used to get the data from Salesforce or an update, and then insert or transform the data in the Salesforce.
There are four types of DataRaptors in OmniStudio, based on function:
- Extract. When you need to get data from one or more Salesforce objects at the same time, use Extract as the interface type while creating a DataRaptor.
- Turbo Extract. When you need to get data from a single Salesforce object, use Turbo Extract as the interface type.
- Load. When you need to insert new Salesforce records and update older ones, use the Load interface. Load can be used in SDL Data Manipulation Language (DML) Operations.
- Transform. The Transform interface doesn’t bring any data from Salesforce, nor does it insert or update data into the organization. Rather, this special type of DataRaptor manipulates data. Transform performs any changes in data that has already been retrieved from the organization or any data coming from outside Salesforce.
Extract DataRaptor is comparatively more complex and provides more functionalities than the other interfaces.
Go to the OmniStudio app. From the dropdown, select DataRaptors.
From the Type dropdown, click New and select the DataRaptor you want to use. In this example, we’ll select Extract.
Name the DataRaptor: DR_Extract_Practice2.
Click Save.
A new console will open with five (5) subtabs:
- Extract
- Formulas
- Output
- Options
- Preview
In Extract, we’re basically adding extract steps. We’re telling the DataRaptor what all objects and fields we need to retrieve.
To add an Extract step, select Account for object. In the Output Path, specify the JSON node, under which all retrieved accounts will be shown (accounts).
In the Filter option, you can set conditions based on which data needs to be retrieved (Id <> “$Vlocity.null”).
Here, we need to do explicit output mappings to determine the output JSON format of the response.
Extract JSON Path — accounts:Name
Output JSON Path — account:name
Preview –> Execute (If we’d given only the name in Output JSON Path, we’d see the output without the account node. So, we can use with this output JSON format based on current requirements.)
Now, let’s see how it retrieves data from multiple objects. Delete the previous extraction step and add a new step: Give Account as the object — -> accounts, Id <> “$Vlocity.null”
This will get all accounts.
Now, let’s pull contacts for these accounts: Extract —> Add —> Contact, accounts:contacts, AccountId = accounts.Id
This refers to all account IDs pulled in the previous extraction step.
Add output mappings for the same: accounts:Name —–> accounts:Name
To add output bindings for contact: contacts:FirstName —> contacts:FirstName
Here, we’ll get two different nodes — contacts and accounts, respectively. It doesn’t give the nested structure we’ll need. That is in the Extract step under Contact, where we already added our Extract Output Path as -> accounts:contacts, which creates all contacts nodes under Account.
And in the output path, we’ll add output mappings for contact: Output — accounts:contacts:FirstName —> accounts:contacts:FirstName
Preview –> Execute
We’ll get the desired output format.
There are a couple more options, such as changing the data type of the output JSON path. You can transform the value coming to your required value using Transform Map Values. In the right pane Input/Output, you can always look for the JSON data format. Extraction Step JSON is the data format used in the Extract step.
Now, if you already know what you want your result JSON to be, you can paste it in Expected JSON and click Quick Match to map the fields. You can also opt for Auto Match or manually map the fields in Quick Match through drag-and-drop.
That’s all for starting with Extract DataRaptors.
— By Bhavya Chanan & Sanjeevani Shukla