How relations work
Every relation requires two fields that reference each other:- The MANY_TO_ONE side — lives on the object that holds the foreign key.
- The ONE_TO_MANY side — lives on the object that owns the collection.
FieldType.RELATION and cross-reference each other via relationTargetFieldMetadataUniversalIdentifier.
Example: Post Card has many Recipients
APostCard can be sent to many PostCardRecipient records. Each recipient belongs to exactly one post card.
Step 1: Define the ONE_TO_MANY side on PostCard (the “one” side):
src/fields/post-card-recipients-on-post-card.field.ts
src/fields/post-card-on-post-card-recipient.field.ts
Circular imports: both relation fields reference each other’s
universalIdentifier. To avoid circular import issues, export your field IDs as named constants from each file and import them in the other. The build system resolves these at compile time.Relating to standard objects
To create a relation with a built-in Twenty object (Person, Company, etc.), useSTANDARD_OBJECT_UNIVERSAL_IDENTIFIERS:
src/fields/person-on-self-hosting-user.field.ts
Relation field properties
Inline relation fields
You can also declare a relation directly insidedefineObject. When inline, omit objectUniversalIdentifier — it’s inherited from the parent object: