Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Can you reference a document in draft mode when creating a new document?

6 replies
Last updated: Apr 8, 2024
Is it possible to reference a document in in "draft mode" when creating a new document (also in draft mode) ? Currently attempting to create a structure that visually represent "sub-pages" but creating a new "sub-page" for a "parent" in "draft-mode" i get this error as soon as the auto-save kicks in:
Apr 2, 2024, 6:32 AM
You would need to use a
weak
reference to be able to reference unpublished documents.
Apr 2, 2024, 3:46 PM
I tried this, mind you i may have implemented it wrong, so i will try again, but just to be clear, can you have a weak reference to a draft, from a document that does not yet exist? And by that i mean is still in the initial phase before autosave has been triggered?
Apr 3, 2024, 5:44 AM
Yes!
Apr 3, 2024, 5:08 PM
Fantastic!
Apr 4, 2024, 6:23 AM
Thank you
Apr 4, 2024, 6:23 AM
Just FYI, we solved the problem by adding
_weak: true
to initial values that contain references. This is essential if you want to be able to maintain references in draft mode.
Apr 8, 2024, 6:10 AM

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?