Posts

Showing posts from June, 2024

Vlocity Facts #42 || How to use Decision Matrix in OmniScript

Image
In one of the previous posts DataMapper Extract Function and Formulas and by using IF(Condition) I have combined 'Dialing Code' and 'Phone Number'. It is okay for limited countries but if you are going to use application across the world then it will be difficult in those scenarios. We can use 'Decision Matrix'. In this post will explain how to create and use decision matrix in omniscript. [Just an example] 1. From App launcher open Business Rule Engine. 2. Click 'New' button and choose 'Decision Matrix', fill details by selecting type as standard. 3. Navigate to related tab and open the 1st version you created now. By using Add Row, Add Column you can add columns, rows. 4. While we add 'Columns' will get option to choose whether it is input or output and Data Type. 5. After adding columns now we need to add rows to mention input and output for the matrix. 6. After filling all the details save the Matrix and activate it by clicking '...

Vlocity Facts #41 || Custom Function to Convert List of Values into Array of Values in DataMapper Formula

Image
In one of the post we used SPLIT() function [Reference -  DataMapper - Function and Formulas ] to split the string. In response we received list of values. Consider one scenario where you have selected multiple values from multi select picklist called Products. In json we will get the response of the multiple select picklist with combination of semi colon[;]. If we need to create child records for those values it is not directly possible, so to divide those values we will use SPLIT() function with splitToken as semicolon [;]. Now will split those products  SPLIT (% Products %, ";" ) Response:  Now we need to use custom function - apex class to convert list of values into array of values. [Similar post where we used custom function to calculate the difference between datatime fields: Using Custom Function in DataMapper] By referring above mentioned post we will create one more method in the same apex class by writing logic in it. I have made some changes to invokemethod b...

Vlocity Facts #40 || Using Custom Function in DataMapper

Image
If we can't find the formulae or functions in Data Mapper's formula tab. Create new apex class containing the needed logic, which can be invoked in DataMapper by using Function(). If we need to call a apex class from omnistudio we need to follow these steps Apex Class should be global with sharing to follow all the sharing settings. The Apex Class must implement the Callable interface. You must override the invokeMethod, which takes the following parameters  String methodName  Map<String, Object> input  Map<String, Object> output  Map<String, Object> option Try to use try and catch block. Then check the methodName and call that method by passing all the parameters. Consider this scenario, we can find the datediff between two dates in DataMapper by using this formula DATEDIFF(date1, date2) --> DATEDIFF(%DOB%,%TODAY%) To find the difference between two datetime fields we don't have standard formula or function in Omnistudio in this case we need to ...

Vlocity Facts #39 || DataMapper - Functions and Formulas

Image
In Data Mapper we can use functions and formulas to manipulate our data or we can change the out come of the values according to our requirement. In this post we will go through some of the formulas which we used in daily requirements. 1. Consider the following example: we have a list of products and need to filter them depending on their color or name. By using FILTER() function we can separate the list which has Green products. FILTER(LIST(Products),'Color == "Green"') Result: 2. We are getting list of contacts or cases and we need to display those records by sorting with DSC or ASC. By using   SORTBY() we can sort the list by using this formula.   SORTBY ( LIST ( Nephews ),  ' Name ',' [ : DSC ] ' ) Result:  Note: we can use [:DSC] only in Data Mapper Transform. 3. We can use SUM(), AVG(), MIN(), MAX() functions to return the Sum/Avg/Min/Max of the list or individual values. Result:  4. We can executes a SOQL query to produce a JSON list of values. ...

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

Image
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 o...