How to Prevent Critical Data from Custom (addError) Validation using a Custom Label and Apex Trigger?

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.

Code

Trigger Code

Conclusion

With this simple piece of code, you have now achieved the unachievable! Preventing critical data from custom (addError) validation was never easier than this. We hope that you liked this simple blog and it was useful for you. We will be back with another blog soon to make your Salesforce experience smooth. Also, if you try out this solution for your business, share your valuable experiences with us. Till then, Happy Learning! 🙂

Our Location worldwide
India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
SR Tower 2nd Floor Hydel Gate Haldwani Uttarakhand 263126 +91-5946359996
USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818