Assign elements of one array to another array

I have a page variable whith this structure:

page variable - fooList (List of objects)
[
{
property1:text
property2:text
property3:text
property4:text
property5:text
},
etc
]

and I have a dataVariable whith this structure:

dataVariable(comes from airtbable rest) - barList (List of objects)
[
{
“property1”:“foo-bar1”,
“property2”:“foo-bar2”,
“property3”:“foo-bar3”,
“property4”:“foo-bar4”,
“property5”:“foo-bar5”,
“property6”:“foo-bar6”,
“property7”:“foo-bar7”,
“property8”:“foo-bar8”,
“property9”:"foo-bar9
},
etc
]

The quuestion it’s quite simple. How can I assign the datavariableList (property1 to property5) to the pageVariable (property1 to property5) with the same elements of the list in each array?

The final result would be:
page variable - fooList (List of objects)
[
{
property1:“foo-bar1”,
property2:“foo-bar2”,
property3:“foo-bar3”,
property4:“foo-bar4”,
property5:“foo-bar5”,
},
etc
]

And obv, if the datavariable have 5 elements in the array, the page variable would have 5 elements with the above structure.

thanks in advance!

Hi Antonio, you can use the Set page variable flow function to do this on the logic canvas. Just choose your data variable as the assigned value of the page variable. If the schemes don’t match exactly (for example the other has 9 and the other 5 properties), you need to bind the properties individually or using a formula.

Thanks for the answer. My problem is I don’t get any formula to assigned the properties and i dont know any formula to do this (the discrepancy of 5/9 fields of my example its real). Please, could you provide me some formula sample of this? Thanks in advance.

Sure! MAP() is a versatile function that is really useful for transforming arrays of objects. Its first input is the array to manipulate (the data with 9 props), and the second one is the operation that we want to perform on each object in the array (just including the first 5 props of the object). The output of MAP() is the manipulated array, so just bind this to the page variable:

MAP(data.firstList, {prop1: item.prop1, prop2: item.prop2., ...})

Awesome!!! I’ve read about MAP function but I don’t know it works with multiple properties! I thought MAP only works with tuples key.value. Thanks for your help!!!

1 Like