Accessing additionalScope from JsCode query

According to the docs for Query.trigger():

  • The additionalScope option allows you to define additional variables to pass to the triggered query when it is run. It accepts an object with any number of key value pairs and all keys will be accessible inside of the triggered query as {{key}}

But the {{object}} syntax is not valid in the javascript body of a JsCode query. Just typing the name of the key gets highlighted as an error and does not seem to work. How/can the additionalScope key/values be accessed?

1 Like

@acoulson Do you have an example you can share?

Agreed, @ScottR! @acoulson it would be great to see a screenshot of where this isn't working

The below example works for me, and the row object value can be accessed in the triggered query under id.row

Since my app is quite complicated, I couldn't provide an example easily, but I will start with a simple test case like yours, @Tess, and work up from there. Will post back with results.

As I've seen it's available as variable in the other query that you trigger.
For easier development you can enumerate the values you'll plan to use with var. BUT let/const won't work for this case.

/* other_query */
var ctx_j, ctx_i; // it works without this line as well

const ctx = {
   i: ctx_i ?? 99, // set default value
   j: ctx_j || 45, // this also works if you prefer this one

console.log("DATA", ctx);
return ctx;

And you can call it from the other place like this:

/* original_query */

  additionalScope: { ctx_j: 5 }
}).then((result) => console.log("Final ctx is: ", result))

Yep, we got it to work. Must have a been a problem elsewhere in my logic.

Can someone help me here

const promises = => {
    additionalScope: {
      "Key": row

return Promise.all(promises);

It is not wokring.
files is the array of s3 file keys, when it is trigerred, it throws 400 error saying, parameter is empty string.

@Tess :point_up_2:

Hi there! It looks like you need to add {{Key}} to the S3 file key field in the downloadReceipts query so that it knows where to reference the additionalScope