How can I transform a list of items (or a collection) in a single bundle to an array that can be iterated through?
I have a working solution that I am looking to simplify or make more efficient.
There are times that a module will return a single record (Project) either through a Search Record module or a Custom API call module. In this example, I'm using both: a Custom API call so I can include parameterValues in the fields list; followed by a Search Record (for the same project) where I map the parameterValues collection that was returned in the response of the API call to the Outputs field of the Search Record module. This creates a dynamic way to pull in all of a project's custom data in the Search Record module without having to hard code the output selections.
In this example, the record that is returned is a single bundle, and that bundle is a list of items (name, ID, DE:this, DE:that). What I need to do is iterate through that list of items, not knowing in advance which DE:fields may or may not be in the list. (I'm using contains on the name to determine if actions should or shouldn't happen, and the value to determine what actions should happen).
I can get a simple array of the DE:fields by using {{keys(**.body.data.parameterValues)}} as an input to a Set Variable module - but this only returns an array of the item names, without their corresponding values.
I then set an Iterator to work through that Set Variable module with an input of {{if(contains(**.value; "DE:QTY"); **.value; "")}} (In this example, if the name of the custom field being evaluated begins with QTY, get the value of the custom field.)
I've managed to make this work, but it feels like I should be able to map both the names AND the values to an array of collections of key:value pairs.
Is there some combination of array functions (get, map, keys?) that I can use in a Set Variable module (or as in input to an iterator module) that will yield an array of all the names and values from a single bundle of items, or is there a way to break that single bundle of items into multiple bundles of key:value pairs?
So from this:
parameterValues (collection)
DE:customField1 : custom value 1
DE:customField2 : custom value 2
DE:customField3 : custom value 3
to this:
parameterValues [array]
1 (collection)
name: DE:customField 1
value: custom value 1
2 (collection)
name: DE:customField 2
value: custom value 2
3 (collection)
name: DE:customField 3
value: custom value 3
TLDR: I want to iterate through items in a single bundle (using both key and value).
