See Sanity in action 👀 Join us for a live product demo + Q&A →

How to display the _id field in Sanity Studio

6 replies
Last updated: Mar 4, 2023
Hey everybody, how can i get _id of item and show it in GUI.This is shema of item:

export default {
  title: 'Objednávky',
  name: 'order',
  type: 'document',
  icon: MdFoodBank,
  fields: [   
      name: 'id',
      title: 'Objednávka:',
      type: 'string',
      readOnly: true,     
      name: 'note',
      title: 'Poznámka',
      type: 'string',
Thank you
Mar 3, 2023, 12:51 PM
You mean in Sanity Studio? All variables that are prefixed with underscore (
) seems to be treated as private variables so they don’t normally show up.
Mar 3, 2023, 1:08 PM
If you really like, I can think of creating a custom component for such purposes
Mar 3, 2023, 1:10 PM
user G
, yes Studio. Component is very good for input, but i just wanna only show up "_id", not edit (my field is readyOnly).
Mar 3, 2023, 1:42 PM
If you try to add a field with the name
to your schema—even if read-only—you’ll get an error and the studio won’t build. Using
name: 'id'
is fine, but by default the studio treats that entirely separate from
. As Dorell mentioned, you’ll want to use a custom component and source the data from your
Mar 3, 2023, 2:50 PM
Oh, ok, thank you
user A
user G
Mar 3, 2023, 4:01 PM
you’re welcome
user M
Mar 4, 2023, 1:15 PM – build remarkable experiences at scale

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

Categorized in