I would like to create as many elements as a count variable specifies, for example:
There is a table that has information about supported equipment
select port_count
from equipment
where id=#[flowVars.equipmentId]
And I've to generate a message that another system out of my control interprets and executes:
<dw:transform-message doc:name="Get value">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
"actions": {
(for 1..flowVars.port_count map {
"action": {
"type": "add_port",
"id": $$
}
})
}
}]]></dw:set-payload>
</dw:transform-message>
Desired result:
{
"actions": {
"action": {
"type": "add_port",
"id": 1
},
"action": {
"type": "add_port",
"id": 2
}
}
}