Saw similar posts in the forum about this but couldn't get my head around them as the examples differed from mine and was hoping for some advice.
I have an app that currently does 3 things.
It pulls up a list of files in a queue using a database query and displays them in a table.
The 'doc-id' column of the table contains values that are used in our API call.
A button in the app triggers a PUT request to the API that will clear out a secific document in the following format: https://website.co/files/{{table_results.selectedRow.data.doc-id }}/mark_as_ignored
This is fine but there can be a lot of documents to clear and doing them one by one is boring.
It seems to me that I can make another query that loops through the column of results and will run a PUT request for each doc id. I've tried doing that myself but I'm in syntax hell now and I'm not even sure what to select as my resource.
Any tips?
THanks for your quick response! Sure, here's a slightly modified version of my query:
SELECT
a.id AS "Doc-id",
l.clientID AS "Client ID",
l.name,
a.status as "Status"
FROM database.accounts a JOIN database.ledger l ON aId = l.id
WHERE l.clientId = {{textinput1.value}} AND a.status = 'PENDING'
ORDER BY a.id ASC;
Then as mentioned previously, I have a button in app that I use to run the PUT request to remove the file that's pending.
Not sure how to use the code you linked to do what I need to do here, let me know if screenshots of the app are required!
Following on from this, here is my attempt at using the code you linked @jSims but it's not running for me:
var rows = [{{tableresults..selectedRow.data.doc-id}} ];
function runQuery(i) {
if (i >= rows.length) {
console.log("Finished running all queries");
return;
}
var data = rows[i];
console.log("Running query for row", data);
query5.trigger({
additionalScope: {
data: data,
},
// You can use the argument to get the data with the onSuccess function
onSuccess: function (data) {
runQuery(i + 1);
},
});
}
runQuery(0);
Not sure how to set my array length to the length of my results in that table..
Don't forget this step! Or it will run infinitely.
Are you seeing the console.log("Running query for row", data)?
Also, line 1 doesn't need to be in [ ] as it's an array already and you've actually made a nested array. (You can confirm that by looking at your left-hand panel .data property on the off chance it's not!)
Ok! Can you write to support so that we can step into your app? If you can link this community post when you write in that would be a huge help! You can use the chat icon in the bottom right of "Edit" mode.