Vlocity Facts #38 || DataMapper Extract - Filter Conditions and Functions

Data Mapper Extract is used to fetch the records from salesforce. We can extract multiple object records based on conditions and filters. Will discuss some scenarios in this post.

1. Consider when we need to extract all the accounts, we can use '$Vlocity.NULL' in filter condition to get all the accounts. 

Note: We need to pass the environment value in quote ['$Vlocity.Null']

2. By using Order By we can filter the records and we can use DESC or ASC. By default records will be displayed in Ascending order. To display in Descending order use  DESC in filter condition. 

Note: Give space between the filed name and DESC/ASC

3. By using Offset we can skip the first N numbers of records while we are extracting. Offset we can use in Pagination scenarios. For more details refer this DataRaptor Offset Filter.

Here I'm passing Skip as a variable in Offset, we can pass the number to skip.


4. We can fetch the contacts based on the Account fields in singe extract step with out creating multiple steps. Consider i need to extract Contacts which are related to Industry - Energy of Accounts.
Note: Use dot notation[.] for standard objects Account.Industry, for custom objects use __r. Order__r.Status.

5. By using And, OR filters we can extract the records based on the conditions. Consider this SOQL query.
Select Id,Name,Active__c,AnnualRevenue,Industry from Account Where (LastModifiedDate != TODAY OR Active__c ='Yes' ) AND (AnnualRevenue != null OR Industry ='Energy')
    a. We can build our Data Mapper Extract with same conditions. 
    b. Limitation of DR is we cannot use brackets directly so we need to follow in this way to get the                same out put.

We can we the query in the debug log. we found 11 records.
Same number of records we got in Data Export.

6. We can use functions in formulas tab to get the desired output. By using sum we can get the total amount of opportunities related to account.
While Mapping Total Amount formula filed I have selected 'Currency' as Data Type that's why in response '$' we are seeing -- it is depend upon the org settings.

7. In extract tab or formula tab to the right side we can see one check box --> 'Show all sObjects Fields'. we can enable that check box all fields which are related to that objects we will be displayed in json format and it will be easy for us in mapping or choosing the fields. 
In mapping from 6th point screenshot if you observe I have used to 2 objects and different paths
a. For Account object --> Account is the path
b. For Opportunity Object --> Account:Opportunity is the path
Both paths of Json will be displayed once we enable Show all sObjects Fields. 





 







 




Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #34 || Getting the details from the URL in a FlexCard and an Omniscript

Vlocity Facts #44 || Communication between Omniscript and Flexcard [Pub/Sub]