Skip to content
Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Entity entry
How-to guide

How to reference an entity from a custom metadata type

You do not create an entity on its own, since standard and custom objects are the entities. But you can reference one through an Entity Definition relationship on a custom metadata type, which lets a configuration record point at an object by metadata rather than by a typed-in name. Here is how to add that field in Setup.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

You do not create an entity on its own, since standard and custom objects are the entities. But you can reference one through an Entity Definition relationship on a custom metadata type, which lets a configuration record point at an object by metadata rather than by a typed-in name. Here is how to add that field in Setup.

  1. Open the custom metadata type

    In Setup, go to Custom Metadata Types, then click Manage Records, or open the type definition. You add the relationship on the type, the same place you add any custom field to it.

  2. Add a Metadata Relationship field

    Under Custom Fields, click New. Choose the Metadata Relationship field type. This is the only field type that can point at object or field metadata rather than storing plain data.

  3. Select Entity Definition as the target

    When asked what the relationship points to, choose Entity Definition, described as the metadata of a standard or custom object. To target a single field instead, choose Field Definition, which resolves through EntityParticle.

  4. Name the field and save

    Give the field a clear label and API name, set who can see it, then save. Each record of the type can now select which object it applies to from a metadata-backed lookup.

Entity Definition relationshipremember

Points a custom metadata record at a standard or custom object. Resolves through EntityDefinition, so it survives renames better than a text field.

Field Definition relationshipremember

Points at one field on an object. Resolves through EntityParticle, for rules that must target a single column rather than a whole object.

Protected versus publicremember

A public custom metadata type cannot relate to a protected one. Decide visibility before wiring relationships, because it constrains what you can reference.

Gotchas
  • You cannot create an entity from this screen. The relationship only references objects that already exist in the org.
  • A public custom metadata type cannot be related to a protected custom metadata type, so plan visibility first.
  • Read the related object in Apex through the relationship field, not by parsing a stored name string, so renames do not break your logic.

See the full Entity entry

Entity includes the definition, worked example, deep dive, related terms, and a quiz.