I have three CDTs that contain some fields with the same value.
I want to create an expression rule that matches them and extracts only the fields that don't overlap.
What function can I use to make it?
Discussion posts and replies are publicly visible
Use symmetricdifference() function.
a!localVariables( local!a: {1,2,3,4,5}, local!b: {1,2,6,7,8}, symmetricdifference(local!a,local!b) )
O/P:
List of Number (Integer) - 6 items
Thank you for your reply.However, because there are many fields in the CDT, it would be difficult to write an array.Is there any other way to achieve this without using an array?For example, how to use the type! function to call the CDT and extract fields that are not duplicates.
you can use a!keys function to achieve your requirement. https://docs.appian.com/suite/help/22.4/fnc_informational_a_keys.html
1. First you need to get the CDT fileds form your CDT using keys function
2. Do a for each on your data and Index the data using your keys
3. Lastly compare the return data that you get form above step
Thanks, it looks like you can achieve your requirement that way.However, I understand step 1, but I don't understand what kind of expression to write for steps 2 and 3.If possible, can you show me a simple code sample?
Here is the sample example. Not sure exactly how your 3 CDTs looks like, consider this is an example
a!localVariables( local!cdt1: { a!map(c1v1: 1, c1v2: 2, c1v3: 3) }, local!cdt2: { a!map(c2v1: 1, c2v2: 4, c2v3: 5) }, local!cdt3: { a!map(c3v1: 6, c3v2: 2, c3v3: 7) }, local!values: tointeger( a!forEach( items: {local!cdt1, local!cdt2, local!cdt3}, expression: a!localVariables( local!keys: a!keys(fv!item), index(fv!item, local!keys, {}) ) ) ), local!finalValues: reject( fn!isnull, tointeger( a!forEach( items: local!values, expression: if( length(wherecontains(fv!item, local!values)) > 1, null, fv!item ) ) ) ), local!finalValues )