vonkendu
2 years agoNew Contributor II
Problem with nested mappings
Hi guys! I am quite new to SnapLogic and I am having a bit of a struggle with transformations. I worked with Mulesoft previously, and honestly, I am kinda trying to do things the same way but it does...
- 2 years ago
Hi vonkendu,
You can use a wildcard operator to select all values from an array or an object, in your case from parameterOne and parameterTwo. After you get the needed array, using the reduce() function you can return the sum of all of the elements in the array.:jsonPath($, "$parameters[*][*][*].parameterTwo").reduce((accum, currentValue) => accum+ currentValue, 0)
jsonPath($, "$parameters[*][*][*].parameterTwo").reduce((accum, currentValue) => accum+ currentValue, 0)
If the name will always be an array with a single element, take the first element of the array to make it flattened.
Please check the attached pipeline.
Hope this helps!
BR.
Ivica