Loading
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Relationship to a Field Definition or Entity Particle

          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
          1. From the detail page of your custom metadata type, click New under Custom Fields.
          2. For the field type, select Metadata Relationship.
          3. 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
            Note Public custom metadata types can’t be related to protected custom metadata types.
          4. From the detail page of your custom metadata type, create another custom field.
          5. For the data type, select Metadata Relationship.
          6. 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.
          7. 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.
          8. 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
          Tip To access relationship fields with Apex, you can use the QualifiedApiName field in the EntityDefinition tooling API object.
           
          Loading
          Salesforce Help | Article