✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Assign Reference Field to Order Document with Characters from ID Field

1 replies
Last updated: Jun 5, 2022
How would I make sure each Order document created is automatically assigned a
field that is basically the last 6 characters of the generated
field, uppercased?My sense told me that I should replace the
with something like
client.transactiion().create(...).patch(<id of order just created>, <functionToAddReference>)
but the issue is that I don't know the
of the just created order, or is there a way to pass it to the patch function?Or perhaps I should just handle the ID generation myself, this way I can perform manipulations on it and provide the
directly in the
The point is that I want to avoid making two API calls for dealing with this. Is that possible?
Jun 5, 2022, 10:59 AM
Got myself sorted with nanoid and a custom alphabet
Jun 5, 2022, 2:21 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?