Transform Engine Loop and Change/Set Value

I need some guidance using the transform engine in an array/object loop.

I have 2 variables: item2.items and preExisiting_items. Each of them is an array of objects with essentially the same data structure and entries.

What I'm Looking to Do

I need to loop through the item2.items array (looking at the value property) to see if that entry exists in the preExisiting_items array. If a match is found, then SET the the selected property to true for that object in the item2.items array.

What I've Tried

I have an Update Variable for item2.items with the below expression:

$var.item2.items|transform:$$.value|in:$var.preExisiting_items.*.value ? ($$|set:selected:true : $$)

When running Debug on this, I get a return of false

I also get false when doing the same expression when doing a Create Variable. I've tried changing, moving, adding, removing parentheses all resulting in different error messages.

Any help or ideas to accomplish my goal would be appreciated. Thanks.

2 replies