I have a requirement that needs me to find the difference between two arrays of CDTs on a field level rather than CDT level. In other words something similar to the function difference() but it compares a particular field rather than all the fields to return the difference.
Example:
array1: { (id: 1, name: bob), (id: 2, name: bill), (id: 3, name: mary) }
array2: { (id: 1, name: joe), (id: 2, name: john), (id: 4, name: mary) }
Difference only in field id returns { (id: 3, name: mary) } because array2 does not contain a CDT with field id: 3
I tried difference(local!array1.id, local!array2.id) but obviously that didn't quite work. Any help is greatly appreciated!
Discussion posts and replies are publicly visible
Might it will helps ,
load( local!array1: { { id: 1, name: "bob" }, { id: 2, name: "bill" }, { id:3, name: "mary" } }, local!array2: { { id: 1, name: "joe" }, { id: 2, name: "john" }, { id: 4, name: "john" } }, a!forEach( local!array1, difference( tointeger( index( fv!item, "id", {} ) ), tointeger( index( local!array2, fv!index, "id", {} ) ) ) ))