You are here:
Create a Relationship to a Field Definition or Entity Particle
Create direct relationships to field definitions or entity particles.
Required Editions
| Available in: Salesforce Classic and Lightning Experience |
Available in: Enterprise, Performance, Unlimited, and Developer Editions You can create, edit, and delete custom metadata type records from installed packages in: Group and Professional Editions |
| User Permissions Needed | |
|---|---|
| To create custom metadata relationships: | Customize Application |
- From the detail page of your custom metadata type, click New under Custom Fields.
- For the field type, select Metadata Relationship.
-
Select Entity Definition.
Entity definition represents the metadata of the standard or custom object that the field definition or entity particle are components of.
Note Public custom metadata types can’t be related to protected custom metadata types. - From the detail page of your custom metadata type, create another custom field.
- For the data type, select Metadata Relationship.
-
Select either:
- Field Definition—A standard or custom field from the entity definition object.
- Entity Particle—A compound value of a standard field or a geolocation field from the entity definition object.
- On the detail page of the custom field, select a controlling field. The controlling field is the entity definition that controls the field definition or entity particle.
- Create a record for storing the metadata relationship and select the field definitions or entity particles that you want to include in the record.
You can now query your custom metadata type or entity definition using Apex.
You can access the field in the CustomField object in the Metadata API. For example, if you create a field definition named SFA_Field, you can access it when viewing CustomField details in a tool such as the Salesforce CLI.
Tip To access relationship
fields with Apex, you can use the
QualifiedApiName field in
the EntityDefinition tooling API
object.Did this article solve your issue?
Let us know so we can improve!

