Reference field not finding documents after converting object to document type

7 replies
Last updated: Jan 27, 2026
I am trying to get a document to refrence other documents of the same type. But I only get "No results" when trying to search for instances of that document type.
The document type was an object up until an hour ago ish, I changed it to a document type because it seems like refrences only works for documents, Then I crated some new instances of that document but cannot find them either.

https://pastebin.com/Fgx3YRP3
Any ideas?
🙂
AI Update

I can see the issue in your schema! Looking at the pastebin, on lines 11-22, you have a duplicate type definition that's causing the problem:

{
  type: "string",  // ← Line 12: This is wrong!
  title: "Related success criterion",
  name: "accessibilityRelatedSuccessCriterion",
  type: "array",   // ← Line 14: This gets overridden by line 12
  of: [
    {
      type: "reference",
      to: [{ type: "successCriterion" }],
    },
  ],
},

The fix: Remove the type: "string" on line 12. It should be:

{
  title: "Related success criterion",
  name: "accessibilityRelatedSuccessCriterion",
  type: "array",
  of: [
    {
      type: "reference",
      to: [{ type: "successCriterion" }],
    },
  ],
},

Why you're getting "No results":

  1. The duplicate type definition was making the field a string instead of an array of references, breaking the reference functionality
  2. Schema needs to reload - After changing from object to document type, you need to restart your Studio
  3. Documents must be published - References typically only show published documents by default, not drafts

Steps to fix:

  1. Correct the schema by removing the duplicate type: "string" line
  2. Restart your Sanity Studio completely (stop and restart sanity dev)
  3. Make sure you've published (not just saved as drafts) some successCriterion documents
  4. Try the reference field again - the search should now work!

You were absolutely right that references only work with document types (not objects), so that change was necessary. Once you fix the duplicate type and restart, everything should work as expected! 🙂

Show original thread
7 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?