Issues with Bulk Deletion

Hello,

I am trying to adapt this solution to allow bulk deletion of records from a MySQL-based table. I have multi-row selection and checkbox column enabled. Here is my code:

var rows = formatDataAsObject(table1.selectedRow.data).id;

console.log(rows);
console.log("Beginning bulk user deletion. Please standby.");

var uids =  formatDataAsObject(table1.selectedRow.data).id;

function runQuery(i) {
  if (i >= uids.length) {
    console.log("Finished running all queries");
    return;
  }
  var uidarray = uids[i];
  console.log("Running deletion for user id:", uidarray);

  stg_MM_delete.trigger({
    additionalScope: {
      uidarray: uidarray,
    },
    // You can use the argument to get the data with the onSuccess function
    onSuccess: function (uidarray) {
      console.log("User" + uidarray + "has been deleted successfully");
      runQuery(i + 1);
    },
  });
}

runQuery(0);


Error message:

Hey @ttam_ei!

When you reference the id in the stg_MM_delete query you'll want to use the same variable name that you're passing as additional scope here:

stg_MM_delete.trigger({
additionalScope: {
uidarray: uidarray,
}

So you might try {{ uidarray }} instead of {{table1.selectedRow.data.id}}. Can you let me know if that works?

There's more info on using additionalScope in this post!

Thanks, that sorted it out!