UseDocumentation Index
Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
Use this file to discover all available pages before exploring further.
defineField() to add a field to an object you don’t own — a standard Twenty object like Person or Company, or an object shipped by another installed app. Unlike inline fields declared inside defineObject, standalone fields require an objectUniversalIdentifier to specify which object they extend.
src/fields/company-loyalty-tier.field.ts
Key points
-
objectUniversalIdentifieridentifies the target object. For standard Twenty objects, import the constant fromtwenty-sdk: -
When defining fields inline inside
defineObject(), you do not needobjectUniversalIdentifier— it’s inherited from the parent object. -
defineField()is the only way to add fields to objects you didn’t create withdefineObject(). -
File location is up to you. The convention is
src/fields/\<name>.field.ts, but the SDK detects fields anywhere insrc/.
Adding a relation to an existing object
To add a relation field (e.g. linking your custom object to a standardPerson), use defineField() with FieldType.RELATION. The pattern is the same as for inline relations but with objectUniversalIdentifier set explicitly. See Relations for the bidirectional pattern.