- July 18, 2017 at 1:46 pm #21083shariq #959
Can we remove custom validation rule through Salesforce apex code?
How to remove custom validation rule through apex code?July 19, 2017 at 4:57 am #21092Radhakrishna #943
It is common practice to have a boolean flag (say ByPass_VR__c), which can be set via Apex Code to skip it. Unless there is such a provision in this validation rule, you cant temporarily disable it via Apex code.
The only ‘work around’ is to set field values such that the error formula doesn’t evaluate to true.
…………..March 28, 2018 at 10:42 am #26801Adarsh #958
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.September 15, 2018 at 2:36 pm #34372
Please Register to reply to this topic. /