6

It's common to get at metadata around a custom object using the common $ObjectType global variable.

{!$ObjectType.Account.Fields.Name.Label}

Can the same be accomplished with custom metadata to get its label or fields?

2 Answers 2

4

The documentation does not state that you can access custom metadata via formulas, so it's pretty safe to assume that you cannot do so. For Visualforce, you could use Remoting or Remote Objects, and for Apex Code, you can use regular SOQL.

1
  • you can access via formula: $CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName. Unfortunately the same syntax does not work in VF pages help.salesforce.com/…
    – NSjonas
    Jun 28, 2019 at 3:51
2

I have some new information

I know this works (API 41):

<apex:outputLink value="/{! $ObjectType.Your_custom_metadata_type__mdt.KeyPrefix }/e" target="_blank">Your Custom Metadata Settings</apex:outputLink>

As does this:

{!$ObjectType.Your_custom_metadata_type__mdt.Fields.DeveloperName.Label}

In formulas it's different:

$CustomMetadata.MetadataObjectName__mdt.YourDeveloperName.FieldName

eg: $CustomMetadata.Links__mdt.Google.Url__c

eg: $CustomMetadata.Links__mdt.Facebook.Url__c

Note no {!} in the above example (for formulas and things like url buttons)

So yes, you can use globals to access your Metadata type records in the same way as normal objects.

2
  • 1
    But still it only access metadata of "metadata" definition like field name, key prefix not the custom metadata record.
    – Ayub
    Apr 6, 2020 at 16:13
  • Actually, no, you can access the records as shown above. Jun 27, 2022 at 21:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .