DataRaptor Extract OmniStudio

In this article we are going to share some basics of DataRaptor Extract. I have published an article with OmniStudio concepts and that covers basic of DataRaptor and I would encourage to read that article first and then come to this. A link to that article is posted OmniStudio Concepts

I am going to refer same definition here: –

DataRaptor Extract

As the name suggests, this is used to extract the information / data from Salesforce Object. It provides ability to filter, sort, limit and apply formulas. This supports queries multiple objects using direct or indirect relationship. Extracted data is presented in JSON format. Basic understanding of JSON is must to properly use DataRaptor. It provides limited ability to extract the data as per our requirement, but we may need to add a DataRaptor Transform action if we have to process the extracted data in completely different structure. We would cover DataRaptor extract in upcoming articles.

Best way to learn a new concept is to try it out. To try OmniStudio you can always request a developer org with OmniStudio. I am sharing this link but it may get changed so just google it and you would find details to request a developer org with OmniStudio. Request Developer Org With OmniStudio

I would be sharing few simple examples. I still love “Hello World” program that I wrote at least in 20 different languages in my last 20 years of IT Carrer. So consider this Hello Worlds example for DataRaptor Extract. Also, we are building foundation only so you may be thinking how this can be used but if you refer the other article, you understand that DataRaptor you can use in Integration Procedure, OmniScripts and Flex Cards. So do not worry about usage and just focus on learning the basic.

Scenario 1 – Extract basic Contact details from Salesforce

We would like to query Salesforce Contact record for a given Contact Id. We would like to extract some basic details like FirstName, LastName, Email, Phone and Id (Id that we pass to query need to be there in output also).

As I mentioned DataRaptor works with JSON. You have to pass some JSON and it would return the JSON. It means two things for us: –

  • DataRaptor is going to read any input from JSON message only
  • Most importantly we need to learn basic JSON. It is simple to learn, and I assume you know the basics and you can always learn or improve.

For this scenario we are going to use below request, and we would be expecting the response as given below: –

Request JSONResponse JSON
{
“ContactId” : “301fdfdfdfdfdfdf”
}
{
“FirstName” : “Matt”,
“LastName” : “Bauer”,
“Email” : “mb@example.com”,
“Phone” : “1212121212”
}

Solution Approach

We got the scenario, and we got a developer org with OmniStudio. We are all set to start our journey. We normally follow a systematic approach that you would be doing when you work on real-time project but here, we can just jump on to development.

1. Prepare Data Mapping Document

Map both Input and Output JSON attributes to Salesforce Object and Fields. This is simple JSON so we know where to get the information, but things would not be same for all scenarios.

For this requirement we know we have to query “Contact” Object and we need to extract FirstName, LastName, Email & Phone and we have to query Contact Id that is actually an ID field for Salesforce Contact Object

2. Create new DataRaptor

In your Salesforce Developer Org Search for DataRaptor

Create a new DataRaptor record using New Button and provide details like Name and Interface Type. Since we are developing a DataRaptor Extract we would be using “Extract” as Interface type. Input Type and Output Type you can leave the default for now as we are going to work on JSON. Other type like XML / Custom most likely you would never use.

3. Configure Extract Step

To configure extract step we need following details.

  • What Object(s) we are going to Query?
  • Do we have any filter condition(s)? If yes then are we going to pass any dynamic values for filter?
  • Any limit, offset, sorting etc.

We already got the details when we finalized our request and response structure and when we completed the field mappings.

4. Configure Output tab for fields to extract

Configure all fields that you would like to be included in your output JSON. You can provide default value during extract. Also, you can define the data type but most of the time leaving it blank should be ok.

Your configuration should look like this

5. Formulas & Options Tab

We are going to skip these two tabs for now and we would cover it in some other articles. We can do lot in formulas and knowledge of Options would be useful in some scenarios.

6. Preview the configuration

This tab allows us to validate our configuration. Most of the time when we work on DataRaptor we would not be having front end ready to connect and test so this provides us ability to unit test the DataRaptor before considering it done.

When we start the DataRaptor configuration we get set of requirements and based on requirement we prepared our request JSON and expected response JSON, so we have everything to validate our work and deploy to integrated environment for testing and integrating with other components like Integration Procedures, Flex Cards or OmniScripts.

In Preview we see three panels: –

  • Input Parameters: – This is where we provide input JSON for our testing. We can use key value pair for simple JSON, or we can move to “Edit as JSON” and add our JSON directly. Most of the time we get JSON from requirement or from OmniScript / IP Data JSON and use that as input.
  • Response: – As the name suggests this is the panel where we see our response. This is the response that DataRaptor would be returning when it is called from OmniScripts / IP / APEX etc…
  • Error / Debug Output: – This panel provides important information mostly used during debugging if something is not working properly. We can validate the SOQL to ensure DataRaptor is generating correct SOQLA as per our configuration

We are done with our first simple DataRaptor that takes an input and returns some output. We are ready to start our journey to explore more of DataRaptor.

Before closing this article, I would add one more requirement and that would give you exposure of working on multiple objects using the relationships between them. Let’s assume we got an additional requirement to extract Account Name also in response. We know Contact is related to Account using AccountId field on Contact that would be holding Id of Account record.

Refer the below image to understand what we have to do to extract Account Name or any other information from related objects. We can definitely use parent notation also to get Account details (refer other image below). I wanted to show you how to use the relation in extract to connect multiple objects but to get details of parent we can just use dot notation like (Contact:Account.Name)

Getting Account Details using parent relation

With this I am closing this article. “As we know learning is a journey and not the destination so do validate the concepts before using them.”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top