'document_id' and 'document_object' not defined

Hello all, I am following the instructions to run a script to edit multiple entries in a users table (firestore).
Tutorial: https://docs.retool.com/docs/firebase-integration
I keep on get the follow error even after I run the javascript code. **'document_id' and 'document_object' not defined **

My javascript code is as follows:

const toUpdate = Users.recordUpdates
toUpdate.forEach((record) => {
  updateDocument.trigger({
    additionalScope: {
      document_id: record._id,
      document_object: record
    }
  })
})

My setup for listing the users and updating the entries are as follows:


If anyone can get any insight I would appreciate it I have been stuck on this for 2 days!

Hello again, I am still unable to fix this issue ! Is there any way I can write a ticket to a support team ?

1 Like

Hi @Isis_Curiel

Thanks for reaching out!

Hmm this code should work as long as you do have pending updates in the table (Users) and as long as the query in your second screenshot is called updateDocument

Here are the next steps I'd recommend:

  1. Run the JS query and check the debug console to see what values are being passed in to the update query via additional scope

2. Check the left panel to ensure that you have the expected values in the .recordUpdates property. It should look something like this (except with different data):

Hey @Tess thank you so much for your detailed explanation. I was able to select multiple entries and updated them even though {{document_id}} and {{document_object}} still appear in red. So in short it's working as expected! Thanks again!

1 Like