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?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityThe 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.
$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName
. Unfortunately the same syntax does not work in VF pages help.salesforce.com/…
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.