Help articles
Invalid configuration for cross-dataset reference
The Studio reports this error when a crossDatasetReference field definition is missing a required property or has an invalid value.
Schema validation reports this error when a crossDatasetReference field definition is missing a required property or has an invalid value. The most common messages are:
The cross dataset reference type is missing or having an invalid value for the required "to" property. It should be an array of accepted types.A cross dataset reference must specify a `dataset`Missing required preview config for the referenced type, followed by the type name.
A valid definition needs:
dataset: Required. The dataset that holds the referenced documents. The name must be lowercase and at least two characters.to: Required. An array of accepted types, with at least one entry.type: Required on each entry into. The name of the referenced document type.preview: Required on each entry into. A preview configuration object.studioUrl: Optional. If set, a function that takes{id, type}and returns a URL.
This check looks only at the field definition. It doesn't verify API tokens or CORS origins, so neither is the cause of this error.
A minimal valid definition:
import {defineField, defineType} from 'sanity'
export default defineType({
name: 'article',
type: 'document',
fields: [
defineField({
name: 'author',
type: 'crossDatasetReference',
dataset: 'production',
to: [
{
type: 'author',
preview: {
select: {title: 'name', media: 'image'},
},
},
],
}),
],
})