Activity › Forums › Salesforce® Discussions › Can we remove custom validation rule through Salesforce apex code? › Reply To: Can we remove custom validation rule through Salesforce apex code?
MemberMarch 28, 2018 at 10:42 am
The other solution is kinda like the second one. Introduce a dummy checkbox field that is not visible to anyone. And let the Validation Rule bypass the record if that checkbox is true. Now, in your trigger, before you update oppsToUpdate, first update that dummyCheckbox to true. In this way, the validation rule will be bypassed. Also, make sure you make the checkbox false as soon as the trigger does its action. In order to do this, you can create a workflow that will do the field update of that dummy checkbox to false whenever the value is true.
Please let me know if you would need any help on this.