API POST Request for every selected table row


How to fire an API POST request for every selected row in a table component?
I have tried to understand the provided JS solution described in below link but it did not help for my specific scenario.

I have a table component were multiple rows can be selected:

I want to fire an API POST request for every selected row.
Were the API POST request contains a JS value:

What steps should I take? Hope to get some information on how the JS query for this specific scenario should look like.


Hi @SanderL

You need to pass a parameter from the selected row event to the query body.

In your POST Raw Body, use a parameter that you can pass as additionalScope when trigger the query.

So, replace {{table1.selectedRow.SHIPMENT}} with {{shipment}}.

In the Table event settings, create a select row event, with Run script action and the following code:

await query1.trigger({
    name: currentSourceRow.SHIPMENT  }

Now, if you select a row, the query should begin, with the correct parameter.

Hope this help.

Hi @abusedmedia,

Thanks for your reply. That worked but is not really what I am looking for.

I want only to fire the API POST requests after clicking a button. So first multiple rows are selected and then via a button that is clicked once, an API request is posted for every selected line.

Hope you can help me with this.

Thanks anyways.

You want the same thing, but to have it triggered by a loop:

When the DO IT button is clicked, a JS Query is called to loop through each selection and fire a POST query:


Thanks @pyrrho,

That is what I am looking for. Just not sure what to put in the additionalScope section. Can you clarify?


Like @abusedmedia was saying this part needs to change (I'll say it's called query1):


and the loop passes the additional scope:

   var resp = await query1.trigger({
        additionalScope: {
          shipment: data[i].SHIPMENT

ie: " For each row, send 'shipment' as a usable variable to 'query1'. "
In query1: " Send the value you receive from the additional scope variable 'shipment' in this request. "

ETA: the loop uses the data array with indexes, not the "currentSourceRow"

Thanks @pyrrho

The API Post request is now posted multiple times for the same shipment. So I selected three table rows, each row having a unique shipment number. The API request was executed three times for the same shipment.

This is the JS query I have:
Schermafbeelding 2024-05-06 om 22.35.32

And this is the API request:

I'm pretty sure you're going to need to move all of the table1.selectedRow data points into the loop query and also pass them through as additional scope variables:

additionalScope: {
          shipment: data[i].SHIPMENT,
          from: moment(data[i].SHIPMENT_ETA.format('YYYY-MM-DD),
          to: moment(data[i].ROUTING_ETA.format('YYYY-MM-DD)

It is strange that only one value would be used if it was looping correctly -- can you show an example of the table's changesetArray (via the State) before the loop is triggered?

I have added the extra data points in the Loop query in the addtionalScope section. Please also find a screenshot of the state info:

My API Post query look likes this now:

When I run the loop query (query17) it is executed for every row but the values ({{shipment}},{{from}},{{to}},{{neweta}}) are null.

I think you misspelled "additional" in your loop query:


That was a stupid mistake. I corrected it and now it works!
Thanks so much @pyrrho

1 Like