01-31-2024 10:00 AM - edited 01-31-2024 10:55 AM
Hello,
I have a requirement to convert the following MuleSoft dataweave code into snap logic...
rpns default '' splitBy ',' distinctBy $ divideBy 245 map ((item, index) -> 'searchCriteria': (item joinBy ','))
I will receive a json payload like below. I could receive hundreds of rpns and I need to divide the rpns list by 245
Example:
Solved! Go to Solution.
01-31-2024 11:47 AM
@Max - please download the attached ZIP file, decompress it, and import the SLP as a POC pipeline.
There are many other ways to solve this and others in the Community may provide you with alternate solutions, but I wanted to try to keep this example fairly simple.
"Split values" uses a JSON Splitter snap and jsonPath function to get the searchCriteria.values array as individual documents. This is done in the event you have more than one set of searchCriteria array elements.
"Split comma separated string" uses a Mapper snap with the String.split() method to change the comma-separated list into an array for each element.
"Split on array" uses another JSON Splitter to turn each array element into a JSON document.
"Group by 2" is a Group by N snap that simply combines the incoming documents into arrays of size N: 2 in this case.
Finally, "Create comma separated list" is another Mapper that uses jsonPath and the Array.join() method to recreate a single string per input document, which is a comma-separated list for your search criteria in the requested format.
Hope this helps!
01-31-2024 11:47 AM
@Max - please download the attached ZIP file, decompress it, and import the SLP as a POC pipeline.
There are many other ways to solve this and others in the Community may provide you with alternate solutions, but I wanted to try to keep this example fairly simple.
"Split values" uses a JSON Splitter snap and jsonPath function to get the searchCriteria.values array as individual documents. This is done in the event you have more than one set of searchCriteria array elements.
"Split comma separated string" uses a Mapper snap with the String.split() method to change the comma-separated list into an array for each element.
"Split on array" uses another JSON Splitter to turn each array element into a JSON document.
"Group by 2" is a Group by N snap that simply combines the incoming documents into arrays of size N: 2 in this case.
Finally, "Create comma separated list" is another Mapper that uses jsonPath and the Array.join() method to recreate a single string per input document, which is a comma-separated list for your search criteria in the requested format.
Hope this helps!