How to properly wait for all queries to get triggered?

try this:

const dataArray = parsedJSON.value;

if(dataArray && dataArray.length > 0) {
  return Promise.all(dataArray.map((item) => {
    return updateTable.trigger({
      additionalScope: {
        quote_adjustment: row.quote_adjustment,
        Quotation_no: row.Quotation_no,
        SKU: row.SKU,
      }
    }));
  }
}
throw new Error("dataArray is null");

alternatively you can set the result of .map to a variable then return Promise.all()

if(dataArray.....){
  let promises = dataArray.map(.......);
  return Promise.all(promises);
}

there's an amazing post by @joeBumbaca covering promises in Retool and here is where you can find more details in the Retool docs.

1 Like