function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Inderjit Singh WaraichInderjit Singh Waraich 

Custom metadata not available in Validation rule ?

I am working on Trailhead Module - Custom Metadata Types Basics and stuck on step 3 > Use Custom Metadata Types in Formulas, Default Values, and Validation Rules.

I am not able to find $CustomMetadata global variable in validation rule and it is throwing error. Any help will be appreciated.

User-added image

 
Best Answer chosen by Inderjit Singh Waraich
Inderjit Singh WaraichInderjit Singh Waraich
Its not working in existing Trailhead Playground orgs, worked only when I create new. Possible old Trailhead Playground missing something or not updated automatically

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Inderjit,

Sorry for this issue you are facing.

The reason being why the above error is thrown is there are no custom metadata types created in your Org.

First, create custom metadata types as suggested in the previous steps then you will be able to see the $custom metadata global variable in the validations.

Please find the sample images from one of my dev org's which I tried just now.

User-added imageUser-added image

Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are facing a similar issue.

Thanks,
Nagendra
Inderjit Singh WaraichInderjit Singh Waraich
Hello Nagendra,
could you please try same in Trailhead playground org? I am not able to see custom metadata there. 

I tried in developer edition it worked.

Thanks
Inderjit Singh WaraichInderjit Singh Waraich
I do have custom metadata type record, see below:

User-added image
NagendraNagendra (Salesforce Developers) 
Hi Inderjit,

I am able to do the same successfully in trailhead playground as well.

Please find the attached images for the same.
User-added image
You can find the URL which indicates this is a trailhead playground.

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
Inderjit Singh WaraichInderjit Singh Waraich
Its not working in existing Trailhead Playground orgs, worked only when I create new. Possible old Trailhead Playground missing something or not updated automatically
This was selected as the best answer
Inderjit Singh WaraichInderjit Singh Waraich
New playground org
User-added image
NagendraNagendra (Salesforce Developers) 
Hi Inderjit,

Maybe there might be something which got updated with trailhead playgrounds.

I am glad that it worked for you in a new trailhead playground.

May I suggest you please go ahead and mark this post as solved so that it gets removed from the unanswered queue which results in helping others who are facing a similar issue.

Thanks,
Nagendra