1

According to this article (https://help.salesforce.com/articleView?id=custommetadatatypes_validation_rules.htm&type=5) we can use Custom Metadata in a formula now. What I'd like to know is how extract the value based on the field label? This article seems to suggest we can only use the field name, not a specific record of the metadata (if there is more than one record).

My Custom Metadata needs to contain different text data to be used based on some criteria ie 'if fieldx = 'ABC' use the text value from the field 'Next Steps' where label = 'Funds Due', else use text from where label = 'Default'. I want to use this for an email template. This is my Custom Metadata, with currently only the 1 custom field for the text.

enter image description here

This is in my records (Manage metadataRecordNameFields)

enter image description here

Should I instead be creating multiple fields (ie 'Next Steps Default', 'Option1', 'Option2'...)and have only 1 record, or should I have multiple records where the field label identifies the value in 'Next Steps' (as I have now)?

If I try and create a formula field, my 'Next Steps' field does not show up - why not? I have set the Field Usage to 'Public'. enter image description here

1

What the article says is to use Name instead of label. Name behaves like the "API" key of a CMTDT record and thus it should be unique and is not expected to change. Instead, the Label is for display purposes, contains spaces and may not be unique.

In summary, in your screenshot, you want to use value contained in the field labeled Custom Metadata Record Name, not Label

If your CMTDT records look like this:

Name|Label|Next Steps
Def|Default|This is my default text
Funds_Due|Funds Due|This is my funds due text

In your formula you should use

$CustomMetadata.MyCustomMetadata__mdt.Funds_Due.NextSteps__c

instead of

$CustomMetadata.MyCustomMetadata__mdt.Funds Due.NextSteps__c
| improve this answer | |
  • Sebastian, if I try and create the formula field, my Next Steps field doesn't come up for selection (I edited my question to add this) - any idea why? – Irene May 4 at 22:13
  • Very likely because it is Long Text – Sebastian Kessel May 4 at 22:13
  • Ok, so does this mean then my idea of using metadata for different paragraphs is not viable? – Irene May 4 at 22:16
  • 2
    I am almost sure it works as long as you use the regular text(255) type. Test it by creating a regular text field and seeing if that one appears on your list. – Sebastian Kessel May 4 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.