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

Automatically Changing Field A Based on Field B

4 replies
Last updated: Jan 18, 2023
Is the current/best way to change field A based on field B (with live updates) still to use a listener on the field and then a patch or mutation?
Jan 17, 2023, 7:04 PM
What kind of change do you mean? You can use the
hidden
and
readOnly
keys. Or are you looking at doing something more complicated?
Jan 17, 2023, 7:46 PM
For example, when field A is set to "title", set field B to "title something else"
Jan 17, 2023, 7:47 PM
If you want it to automatically change, then you will still want to use a listener and a patch. Otherwise, you can do something like a document action that updates the value of B when the document is published.
Jan 17, 2023, 11:09 PM
Well, they'd want to be able to change it, so yeah, a listener. It's tricky because we need to fill if empty, otherwise, don't change it. In our situation, it's
<title>...</title>
tag vs. "page title" in
<h1>...</h1>
. The use case is that it's almost always the same, but not always, but it's a pain for them to enter twice, so...thanks again,
user M
you're our rock (star)!
Jan 18, 2023, 2:56 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?