Variable setValue doesn't work

I want to hit all the rows in listbox1 to trigger query1, and I have to change the value of variable for each row. But the value doesn't change. Here's my code.

const dan= listbox1.data.map(row => {
variable.setValue(row.id)
console.log(variable.value)
return query1.trigger({
additionalScope : {
id: row.id,
},
})
)

return Promise.all(dan)

Hi @feoifwwoewf, welcome to the forum! :slightly_smiling_face:

There is an advanced setting for the JS query to keep variable references inside the query in sync with your app. I tested this without it being turned on and I only got the last value from the iteration when running variable.setValue(). In your case you say the value doesn't change at all, is it keeping the default value?

Here is the comparison of my query with and without enabling setting:

First, here is where to find it under advanced settings:

When it is not enabled:


Note: setVariable is an async function so I'm using async/await to wait for that line to run, but it still only shows the value of the last run.

When it is enabled:


Note: The value of the variable inside the query is in sync.

Let us know how if it worked for your use case!