Passing Input to a Integration Procedure, the syntax is different for passing Input of type primitive (String int etc..) and passing List/Obj as Input to IP from a FlexCard.
Passing a Primitive type the syntax is straight forward. {node} node being the variable that you want to pass as Input to IP.
Passing a List/Obj the syntax is like {records[0].node} node being the list/obj that you want to pass as Input to IP.
Data Source of the FlexCard is {"userdetails": [{"name": "user1", "age": 25},{"name": "user2", "age": 20}],"testInput": "test"}
The “testInput
” field is of type String.
And “userdetails” is a list.
So passing the data to Integration procedure this is the syntax.
Resources:
1. Video: https://youtu.be/1HR3crfvAmQ
Tag: Salesforce
How to Fix Uncommitted work pending Error in Integration Procedures ?
This a common error that we see when we use a HttpAction in an Integration Procedure.
We see this error usually when we are calling a DataRaptor action before our HttpAction, or making a DML operation before a Http Action.
The Reason:
- The Salesforce platform prohibits Data Manipulation Language (DML) operations before HTTP external callouts. Therefore, if an HTTP Action follows a DataRaptor Post Action we encounter this error.
Fix:
- Enable Chain On Step for the DataRaptor Post Action. Do this to avoid the Salesforce error indicating you have uncommitted work pending.
If you are testing it in preview mode under Option change “chainable” to true.
And if you call the Integration Procedure from a OmniScript then you need to check the “Chainable” option under Remote Properties of Integration Procedure Action.
Resource:
2. Video: https://youtu.be/ZOk3TtHNIN4
Leave a Reply
Integration Procedure List Action
List Action in Integration Procedure ?
List Action is a part of the Integration Procedure that allows merging, sorting, and modifying multiple lists of items.
Properties of List Action:
1. List Merge
2. Sort List
3. Modify List
- List Merge
- Merge List in an Integration Procedure refers to the process of combining two or more separate lists into a single, unified list. This can be useful in integration procedures when you need to combine data from multiple sources into a single list.
- In MERGE LIST ORDER value fields we have to add the list name, the order depends on which list value should have the priority to override the value of a given field in a list.
Example 1: Simple Merge - Merge Fields value field without checking the Advance Merge checkbox, expects a field on the bases of which the merging of the list would happen. eg: “id”
Using the above configuration and the following Input the response shows that the 2 list got merged based on the “id” field. - Example 2: Has Primary
For this example we will use the same list as in the above example, only think is we will check the Has Primary checkbox and in the Primary List Key field we will add a list, which will be our primary list, so when we merge the list we will only get nodes/objects from the primary list and not add any node that doesn’t have a matching key from a non primary list.
In the following screen shot we can see the response doesn’t have the node with “id” 4, as it was coming from Orders2 list which is not the primary list, in our case Orders1 is the primary list and only nodes from that list will be returned. - Example 3: Advance Merge with One Key
For this feature we will have to check the Advance Merge checkbox. We use Advance Merge when we want to merge list based on some key but the key name are different in different list.
ex: Order.id = OrderItem.orderId.
For this example we will use Orders2 list and OrderItems and the configuration as follows.
In the Advance Merge Map the List Key field expects a list and Matching Path expects the key from the list in List Key and Matching Group is a way to configure the group we will be matching based on.
So the Matching Group for both the entries are 1 as they are part of the same group (id).
The full configuration of the List Action .
The Input and Response - Example 4: Advance Merge With Two Keys
For this example we will merge lists based on 2 fields “id” and “type”.
ex: Order.id = OrderItem.orderId AND Order.type = OrderItem.itemType
So the configuration is very similar to the Example 3, we will only add 2 more entries to Advance Merge Map for type matching.
Input and Response
The response we can see that the object with “orderId” 2 is not merged as the “itemType” did not match with “type” from the orders list.
- Sort List
- This is used to arrange the list in some order based on some field like alphabetical, numerical, or date order.
- Sorting a list can be useful in integration procedures to ensure that the data being integrated is organized and consistent.
- The default will display the response as ASCENDING order.
- Example 5: We will use the exact same configuration as above just sort the response base on the “orderName” field.
- Modify List
- We can add remove and modify list objects with this action.
Example 6: Dynamic Output Fields can be used to only return the fields as required.
For this example we will pass an input “required_fields” which will pass a string with comma separated field names “orderName,orderId,itemName,itemType,itemId“. - Example 7: Filter List Formula
Filter formula that we can use to filter the List ex:- using the above example we can use “itemType == “mobile” in the Filter List Formula to filter the list to only return the nodes that have “itemType” as “mobile“.
Resources:
1. Video: https://youtu.be/6lwYg_sRRfo
2.DataPack: https://github.com/TenByZenn/OmniStudio-Examples/blob/main/IntegrationProcedureExamples/IP_LIST_ACTION_EXAMPLE.json
- We can add remove and modify list objects with this action.
Leave a Reply
Integration Procedure Loop Block
Loop Block in Integration Procedure?
A Loop block is a group element in an Integration Procedure, that is use to loop over a list/ array of objects. It works like a for loop in traditional programming where we loop over list to perform actions on the list.
We can perform Conditional Execution by adding conditions in the ‘Execution Conditional Formula’ of a Loop Block to decide whether to execute the whole Loop Block, so checking for conditions that would need to be true before we execute the Loop the first time. for example :
Here we will check if the totalPrice is set to 0 to make sure we execute Loop Block.
If we want to have some action to be executed based on some condition that depends on the data in the List objects in a loop, we can do that in the ‘Execution Conditional Formula‘ field of a action like:
Here we are checking if the ListPrice in each object of the loop is less than 100, then we execute the action.
Example:
Now to understand the Loop Block lets work on a example where we use a DataRaptor to get a list of OrderItem for a Order, which returns a list of objects, where each object has the ListPrice of the OrderItem. We will then Use the DataRaptor to get a list and then pass the list to the Loop Block and calculate the total price of the order.
Data Raptor (DR_GetOrderItem)
Now let’s create an Integration Procedure.
Integration Procedure (IP_Loop_Block_Example)
First start by adding a Set Value Element to the IP call it Ini_Total_price, where we will set the a variable totalPrice as 0 to initiate the totalPrice variable.
Set Value (Ini_Total_price)
Adding a Data Raptor(GetOrderItemPrice) to the IP.
Data Raptor Action (GetOrderItemPrice) calling DR_GetorderItem
The response from DR is saved under the name orderItemPriceList.
Now Lets add the Loop Block to the IP (LoopBlock1)
We will pass the list orderItemPriceList that we got from the DR action GetOrderItemPrice from above. We also have the Execution Conditional Formula added to demonstrate how it works.
Now we will a Set Value (calculateTotalPrice) action in the LoopBlock1 block.
Set Value (calculateTotalPrice)
The Set Value Element is called calculateTotalPrice
1. Name of the variable we are trying to set (price)
2. Value of the price. Here we are summarizing the totalPrice and the price of the current item =%totalPrice%+%orderItemPriceList:ListPrice%
%totalPrice% comes form Ini_Total_price and then we add the price of the current item in the loop %orderItemPriceList:ListPrice%
%List:Key%
3. The Path of the response (price)
4. Assigning the value back to totalPrice so the next time we have the value summarized up till this point in the variable totalPrice.
5. Execution Conditional Formula to only add prices that are less that or equal to 100.
<= 100. Same syntax as 2.%orderItemPriceList:ListPrice%
Now the last step is to add the Response Action (ResponseAction1)
Response Action (ResponseAction1)
We are returning a response Additional output response of the Response Action
as totalPrice and the value %totalPrice%
The totalPrice 168 as we are not adding 119 from here, as we added an Execution Conditional in calculateTotalPrice.
Notes:
1. The list that we loop over in the Loop Block can only be a list of Objects, if the list is of String or ints it will not loop over it.
Resource:
1. Datapack: https://github.com/TenByZenn/OmniStudio-Examples/blob/main/IntegrationProcedureExamples/IP_Loop_Block_Example.json
2. Video: https://youtu.be/t6uIRZS312Y?si=xhNhmfXsn1YKpWAo
3. https://help.salesforce.com/s/articleView?id=sf.os_process_arrays_using_loop_blocks_49200.htm&type=5
Leave a Reply