How to update a Firestore document with an autogenerated id?

Hi!
I’m working with Firebase Firestore and have created a document with an autogenerated ID. Now, I need to update this document via make.com, but I’m not sure how to correctly reference it given that I don’t have the ID stored.

Could someone explain the best approach to update a Firestore document when the document ID was autogenerated? Is there a way to retrieve and update this document directly, or should I always work with a known ID?

Thanks for your help!

Hello @zigxag and welcome to the Make Community!

If you have a Firestore document ID you can use it in subsequent modules.

If you need it in separate scenarios you’ll need to store that ID or find a way to search for it using some other identifying information about the document.

You can either store the id itself like @Donald_Mitchell mentioned or use the search module to find the specific document by a matching criteria.

Hope this helps!

I have the firestore ID saved in a sheets document. I search the document and find it, but when I use the maping toggle and enter the firestore ID as a variable pulled from the google sheets the document doesnt gets updated. It gets duplicated with just the fields I updated. So now I have two records with the same ID.
I also tried to add the field in the delete section to force the “update document” but no to no avail.

Alternatively when I use the drop down to find the document instead of mapping it myself it works fine, but it isnt dynamic.

When it get duplicated its a different document id correct? I’m suspecting something within the document path name is not being copied or mapped exactly the same.

Try under “Input document path” change that to mapping and enter in the full path.

I agree. I cant figure it out because I try comparing the input for both way(mapping it and using the dropdown) and it all looks the exact same.
Nonetheless when I map it, it seems to create a new document instead of updating the existing one. In the screenshot the IDs are the exact same.

The id is generate by Firestore or is it being generated on your end? Firestore would throw an error if a duplicate document id is generated.

Its most likey that your issue is in the step where the document path is being written.

In the screenshot above I am entering the firestore id in the document path as a variable pulled from sheet.

So I would think that it would use it and not duplicate it??

There is a difference between the two ids. The j in one is capitalized and the other lowercase. Your issue might be steming from the step you are recording the document ID into the Google Sheets.

Oh wow. Such a rookie mistake. I asked Chatgpt to transcribe the IDs from firebase for my document and there were some mis matched. Thank you for catching that! the mapping worked fine after that!

1 Like