Create Validation Rules Through Code
#Salesforce #ValidationRules #ApexCode #CreateValidationRulesThroughCode What is the Validation Rule in Salesforce? Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False” Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value Can we create a Validation Rule through code? => The answer is yes. We can create a validation rule through code. But, for this, you must have a MetaDataService Class in your org. Here is a link, MetaDataSerivce Class . The code is given below to create the Validation Rule:- MetadataService.MetadataPort service = new MetadataService.MetadataPort(); service.SessionHeader = new MetadataService.SessionHeader_element(); ...