local!test1: { { item: "stapler", name: "Mike", countryId: 1 }, { item: "printer", name: "Larry", countryId: 2 }, { item: "laptop", name: "Mike", countryId: 1 }, { item: "glass", name: "Mike", countryId: 3 } },
Discussion posts and replies are publicly visible
a!localVariables( local!test1: { { item: "stapler", name: "Mike", countryId: 1 }, { item: "printer", name: "Larrys", countryId: 2 }, { item: "printer", name: "Larry", countryId: 2 }, { item: "laptop", name: "Mike", countryId: 1 }, { item: "glass", name: "Mike", countryId: 3 } }, a!forEach( items: union(local!test1.countryId,local!test1.countryId), expression: displayvalue( fv!item, local!test1.countryId, local!test1, null ) ) )
Wow! you're amazing. Could you please explain the expression section?
From Appian docs, displayvalue: "Tries to match a value in a given array with a value at the same index in a replacement array and returns either the value at the same index or a default value if the value is not found."
https://docs.appian.com/suite/help/23.3/fnc_conversion_displayvalue.html
So it is like: Iterate on unique countries, find the index of the first item in the list of ALL the countries, and return the full record at that same index.
This is a great function once you understand how it works!
Thank you so much !. I really appreciate it. I will try to play around and familiar with this function.