
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see the issue! The problem is with how you're trying to concatenate strings in GROQ. You're using _firstName_[0] which is trying to reference a field with underscores wrapping it, but that's not the correct syntax.
In GROQ, you need to use the + operator between string values, and you should reference fields by their actual field names. Here's the correct syntax:
"initials": firstName[0..1] + lastName[0..1]Or if you want just the first character of each:
"initials": firstName[0] + lastName[0]Key differences:
firstName and lastName (not _firstName_ and _lastName_) unless your actual field names have underscores[0..1] gets the first character as a string, while [0] also works for single characters+ operator between the two field references combines themFull example in a projection:
*[_type == "person"]{
firstName,
lastName,
"initials": firstName[0..1] + lastName[0..1]
}This would turn someone named "John Doe" into initials "JD".
If your field names actually do have underscores (like first_name), then use those exact names. The important part is removing the extra underscores that were wrapping the field names in your original attempt, and making sure the + operator is positioned correctly between the two values you want to concatenate.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store