Loop through an array and get values from storage

Hi,

I’m trying to loop through an array and transform it by getting the values from storage. Tried value mapper and node mapper and can’t make it work. There are no guides about it as well.

Say i have this data structure

{
"id": 1,
"values:[
{
"attribute_name_id": 1,
"attribute_value_id": 1,
},
{
"attribute_name_id": 2
"attribute_value_id": 3,
}
]
}

i need to transform it to a new array but the values will need to come from an entity that is already in storage

"id": 1,
"values:[
{
"name":  "text from storage based on 1",
"value": "text from another storage based on 1"
},
{
"name":  "text from storage based on 2",
"value": "text from another storage based on 3"
}
]
}

Hi @brethren,

Thank you for posting your question in the Alumio forum.

In order to loop through an array, you can use an entity transformer prototype called “Node, transform nodes”.

Under the “Node, transform nodes”, you can get any storage entity as much as you want.

Hi @Gugi ,

Thanks. However, I’m trying to found out the following now

  • the entity from the storage is an object so i just need the 1 field from there. Is this possible without creating another transformer?

  • i need to access a parent value to concat from within the array. how do i do this?

Unfortunately, getting only one property from a storage entity is impossible at the moment. Therefore, you should put more transformer(s) to remove the other properties you don’t actually need.

When you are inside, a “Node, transform nodes”, it is not possible to get a value outside the array. I would suggest copying the values you need from the parent to the array using Recursively copy values to children.