OmniStudio (Integration Procedure): Filtering One List Using Values from Another List
Hey there! Today, I'm excited to guide you through filtering a list of objects by comparing values from another list of objects using the Integration procedure. ๐
Let's work with the JSON below. We've got two lists here - "PrimaryList" and "SecondaryList", each with its unique properties. "PrimaryList" has "PrimaryName" and "PrimaryValue", while "SecondaryList" features "SecondaryName" and "SecondaryValue".
Input List
{
"PrimaryList": [
{
"PrimaryName": "Name1",
"PrimaryValue": "Value1"
},
{
"PrimaryName": "Name2",
"PrimaryValue": "Value2"
},
{
"PrimaryName": "Name3",
"PrimaryValue": "Value3"
}
],
"SecondaryList": [
{
"SecondaryName": "Name1",
"SecondaryValue": "Value1"
},
{
"SecondaryName": "Name2",
"SecondaryValue": "Value2"
}
]
}
Output List
{
"PrimaryList": [
{
"PrimaryValue": "Value3",
"PrimaryName": "Name3"
}
]
}
The final list, called "PrimaryList", is made by removing "Name1" and "Name2" because they are in "SecondaryList". The goal is to have unique items based on "PrimaryName".
Step 1:
Create an Integration procedure named "FilterListBasedOnValueFromAnotherList", you can keep any name, which seems logical.
Step 2:
Have a SetValue node added and name it "ReturnList". We will use this for appending out matching nodes.
Step 3:
Now, add a loop block and loop on the primary list, loop on each node and use the Filter function in combination with ListSize.
The Filter function generates a subset that fulfils the given criteria, and then ListSize is employed to verify if the resulting list's size is identical to that of the SecondaryList. If the sizes match, the node is added to the ReturnList in Step 2.
Step 4:
Finally returning the ReturnList:returnList as a "PrimaryList"
Integration Procedure example.
Here is the export of the Integration procedure which can be directly imported.
Subscribe to my newsletter
Read articles from Nagendra Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nagendra Singh
Nagendra Singh
Allow me to introduce myself, the Salesforce Technical Architect who's got more game than a seasoned poker player! With a decade of experience under my belt, I've been designing tailor-made solutions that drive business growth like a rocket launching into space. ๐ When it comes to programming languages like JavaScript and Python, I wield them like a skilled chef with a set of knives, slicing and dicing my way to seamless integrations and robust applications. ๐ฝ๏ธ As a fervent advocate for automation, I've whipped up efficient DevOps pipelines with Jenkins, and even crafted a deployment app using AngularJS that's as sleek as a luxury sports car. ๐๏ธ Not one to rest on my laurels, I keep my finger on the pulse of industry trends, share my wisdom on technical blogs, and actively participate in the Salesforce Stackexchange community. In fact, this year I've climbed my way to the top 3% of the rankings! ๐งโโ๏ธ So, here's to me โ your humor-loving, ultra-professional Salesforce Technical Architect! ๐ฅณ