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
Sonali_takkeSonali_takke 

Bypass Validation Rule Issue

Hi Developers,

  • I have created Bypass_Validation checkbox with default value as FALSE.
  • I updated Validation Rule Formula to include the line Bypass_Validation = FALSE 
  •  I am setting it to TRUE to bypass validation rule through apex\
  • Now I need to Set Bypass_Validation back to False so that Validation rule will fire when user creates records through UI.
  • I have created new process builder on that object to set it FALSE but when process builder sets it to FALSE it again trigges validation rules.
Can anyone guide me on this issue?

 

ShirishaShirisha (Salesforce Developers) 
Hi Sonali,

Greetings!

Can you please check this blog where we have the steps to make bypass the validation by creating the checkbox and with the Workflow.

https://www.mandsconsulting.com/how-to-bypass-validation-from-apex-across-objects-salesforce/#:~:text=Be%20sure%20to%20update%20your,updating%20the%20Last%20Interview%20Date.https://www.mandsconsulting.com/how-to-bypass-validation-from-apex-across-objects-salesforce/#:~:text=Be%20sure%20to%20update%20your,updating%20the%20Last%20Interview%20Date.

Also,please check the sample code for bypassing the validation rule using Apex:

https://salesforce.stackexchange.com/questions/191192/how-to-bypass-validation-rules-when-running-apex-class

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri