I have a CMDT SObject called MyCmdt__mdt
It has two fields
Field Name | Field Type |
---|---|
SObjectType__c | Metadata Relationship (Entity Definition) |
SObjectField__c | Metadata Relationship (Field Definition) |
I want a validation rule that ensures that the value of SObjectField__c
is a Checkbox field
My VR looks like this:
NOT(ISBLANK(SObjectField__c)) &&
SObjectField__r.DataType <> 'Checkbox'
But this does not work, the VR always fires even when I choose a Checkbox field.
The documentation of FieldDefinition states
Data type of the field, for example Text(40) or Date/Time. The values are defined as they are in the user interface, not the corresponding API data type names. Available in Tooling API starting version 34.0.
I can see by doing SOQL on CMDT that the value that comes back for the SObjectField__r.DataType
is in fact Checkbox
- This Custom MetadataTypes and Validation Rules doc is silent on an example of using the
FieldDefinition.DataType
in a VR within a CMDT SObject. - This Q&A suggests stuff gets wonky in an undocumented way
So, how do I resolve this?