How to Prevent Critical Data from Custom (addError) Validation using a Custom Label and Apex Trigger?
Sumit Mishra
Technology Enthusiast | A Coder | Salesforce Makes Business Possible | 22x Salesforce Architect
We know how important it is to have updated data of your customers. Often, we create validation in our site to get the customer details like name, email id, status, etc., in a proper format. But many times, we want to access critical information from our clients irrespective of whether it meets our criteria or not. So, in this smart solution, we will tell you how you can bypass those validation criteria to meet the critical information.
How does this solution work?
We have created a code in the custom trigger where a user can mark in the label the critical fields and need data anyhow. So, whether or not the data meets the validation criteria but it would let you have control over the critical data.
Hence, we have used a custom label to store critical field API names with comma(,) separation.
This trigger prevents updates on the Account record if an account is Inactive. But if critical fields are updated even if an account is inactive, then custom(adderror) validation is not fired.
Thus, making critical information updateable at any time.