I'm new to Retool, and I'm currently experiencing an issue with updating multiple documents in Retool using Firestore.
Here's a brief overview of the issue I'm facing: I have created a Retool table that displays data from a Firestore collection, and I have enabled multi-row selection to allow users to select multiple rows.
My goal is to update multiple documents in Firestore by clicking a button in Retool, but I'm having trouble figuring out how to do this.
Here are the steps I've taken so far:
Created a Retool table that displays data from a Firestore collection
Enabled multi-row selection in the Retool table
Created a button in Retool that triggers a query to update a single document in Firestore
Tested the query to update a single document, and it works correctly
Attempted to modify the script called when clicking on the button to first, retrieve the ids of the selectedRows in the Retool table and then call the query for each id in order to update multiple documents.
I would greatly appreciate it if you could provide any guidance or assistance in resolving this issue. Please let me know if you need any additional information from me.
Can you try using query9.trigger({additionalsScope: {id}}) instead of query.run() in your script, and then replacing {{Exercises.selectedRow.data['0'].id}} with just {{id}} in the settings for query9?
There are some more docs here that might be helpful! Let me know if that works
Would you mind posting a screenshot from your Debug Tools that shows that query being called? We might be able to inspect the additional scope there:
Also curious to see what is returned by the updateExercise query
As another thought, you mentioned triggering the query from selectedRow originally but this seems to trigger from recordUpdates - was there a change in your intended workflow?
I have a table that displays all the exercises in my collection. However, since it may contain thousands of rows, I would like to allow users to select the lines they want to update.
To achieve this, I have implemented a functionality where users can select the rows they want to update and then click on a button called "Edit Multiple Exercises". This opens a modal containing a new table with only the selected rows, which the user can then edit. Once the user saves the changes made in this new table, it updates the original table.
When running the handleUpdate method separately, outside of the table, the updateExercice query is called first, followed by the handleUpdates JavaScript function.
I was able to resolve the issue. It turns out that the reason why the updateDocument method was not being called was because it was retrieving an empty array.
I realized that this was due to another method being called when the "Save Changes" button was clicked, which was clearing the selectedRows and, as a result, the recorded updates...
Thank you for your support and assistance throughout this process.