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
ScualScual 

validationRule on CustomMetadataType

Hello all,
i need to create a validationRule on a Custom Metadata Type
Custom Metadata Type : ConfigMatchingPhone__mdt, 
Field : ObjetType__c (EntityDefinition)
Field :LookupField__c(FieldDefinition).

Value on my Record are :
ObjetType__c : Contact
LookupField__c : Account

SOQL query: select ObjetType__r.QualifiedAPIName,LookupField__r.DataType from ConfigMatchingPhone__mdt

Result :
ObjetType__r.QualifiedAPIName: Contact
LookupField__r.DataType : Lookup(Account)

i want to check data LookupField__c is a lookup of Account.

ValidationRule :
NOT(CONTAINS(LookupField__r.DataType,"Lookup(Account)"))
this is not work!
How i can do that?
Please help
Best Answer chosen by Scual
ScualScual
Solution 
ValidationRule :
LookupField__r.DataType !="Lookup" /* on all user language */
this is work!
i can't check if the data LookupField__c is a lookup on Account SOBject.

how work DataType FieldDefinition?
DataType return the label of the type.
ex:
phone type :  "Phone" (English), "Téléphone"(French)  /*use $label for the condition*/
Lookup Type :"Lookup"(English),  "Lookup"(French)

All Answers

ScualScual
How used the field DataType FieldDefinition in CustomMetadataType' validationRule ?

https://help.salesforce.com/articleView?id=custommetadatatypes_field_validation.htm&type=5

 
ScualScual
Solution 
ValidationRule :
LookupField__r.DataType !="Lookup" /* on all user language */
this is work!
i can't check if the data LookupField__c is a lookup on Account SOBject.

how work DataType FieldDefinition?
DataType return the label of the type.
ex:
phone type :  "Phone" (English), "Téléphone"(French)  /*use $label for the condition*/
Lookup Type :"Lookup"(English),  "Lookup"(French)
This was selected as the best answer