Hi,
The task is quite harder
you have arrays of input data, and when you iterate through recordToUpdate, you are trying to put whole array thepackagelink into each field, which refuses to get it. Instead, you need to add iteration of thepackagelink.
You don’t need to create inner loop.
Imagine your recordsToUpdate is [111,222,333,444,555], I omitted string quotes to simplify.
Your package link variable is something like [linka,linkb,linkc,linkd,linke] , so you need to put index, which iterates from 0 to 4 (in this case)
i’m usually not using ‘for’ loops. so I can’t tell what is ‘best practice’, but there’s one option:
let count=0
let updates = new Array
for (let record of recordsToUpdate){
updates.push({
id: record,
fields:{
[packagelinkFieldName]: {name: thepackagelink[count]}
}
})
count++
}
I just solved a similar puzzle so I even can show a demo
that’s why your field refused to get value:
Another way, to avoid “spawning unnecessary entities” (I don’t know correct English sentence for that), index may follow array size, which increases together with loop counter.
I hope, you will do the rest :slightly_smiling_face: