+ Start a Discussion

Validation rules creating probs for scheduled jobs

Hi All,


I have some batch jobs in my org. They are working fine. I faced some isuus when I created some validation rules for making some fields mandatory. I get errors for my test classes that there must be those mandatory fileds in test classes which have been made mandatory through validation rules. I am able to run batch jobs only when i deactivate those validation rules.


I think there must be some ways so that test classes are not imacted directly by validtaion rules else every time i create a validation rule I have to make changes in test classes.


Can anybody please suggest some remedy for this. 

Thanks in advance!






Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Create a custom setting of type hierarchy with a checkbox and mark it as true/false for the user running the batch job... and include that custom setting in validation rule so that it will be skipped...


For test classes you could do the same by setting running user as the user with that custom setting...