Loop over the values of a multiselect to pass them to a MongoDB query

Hi all,

In one of my apps, I have a multiselect component in which I can select multiple brands.
Next, I need to project each of these brands in a MongoDB query, however I fail to loop over the brands.

The below works in the Projection field to access the first brand:

{"Country": "$ccode",
"value_{{brand_selector.value['0']}}": "${{brand_fact_selector.value.substring(2)}}.{{brand_selector.value['0']}}.clcf"
}

In order to loop over all values of the brand_selector I try:

{"Country": "$ccode",
{{brand_selector.value.map(b => "value_${b}": $${brand_fact_selector.value.substring(2)}.${b}.clcf").join(", ") }}
}

The resulting string looks like a Json object, however I get an error that claiming it is not. Copy pasting the preview of the projection gives me no probem in other MongoDB clients. Also in the debug tool the projection looks OK.

Please help on how I can loop over the brands selected in the multiselect.

Thanks,

Dirk