I'm Having difficulties passing additional scope variables

Hello!

I'm trying to do a multiple row updates using the following code here:

main_table.recordUpdates.forEach((element) => {
  console.log(element.id)
  update_table_new.trigger({
    additionalScope: {
      index: element.id
    }
  })
})


It's a Retool Database Beta resource.

But as you can see, and as I tried to to work around it, the additional scope doesn't seems to be getting to the query. Maybe I'm not using the triggers correctly. What could I've be doing wrong here? If you need more information, let me know.

I've also tried to check the documentation, videos and multiple forum pages but I'm a little bit lost on how to solve this issue, so I apologize if this issue has already been solve multiple times.

You can try something like this:

const promises = main_table.recordUpdates.map((h) => {
console.log(element.id)
  return update_table_new.trigger({
    additionalScope: {
     index: h.id
    },
  });
});

In case there's confusion about the index variable throw a linting error - that is actually expected, we have an internal ticket to address it since it has caused confusion for others before :sweat: There's more on using additionalScope in this post!

Out of curiosity, is there a particular reason you're not using the bulk update action type for this query?

ScottR, Kabirdas, Thank you so much for your replies, I've actually found the answer to the issues. Been wanting to return to forums and reply to these post and many others to help other who might have the same issues as myself.

I'm new to Retool so I wanted to avoid using SQL since I thought I was going to made even more mistakes since I'm more confortable with javascript so I wanted to relied more on the GUI mode.

I tried using bulk updates but I wasn't understanding the logic of it and on the documentation it seemed that was single by singles rows, then I notice that if you only put the object like table.changesetObject retool automatically updated those rows for you.

And thank you Kabirdas, that post just helps with something I was looking at the moment :wink: