0

We have a multi level approval process chain for a case record type. I have a checkbox field, which, when checked would cancel the case. Whenever the current user/approver cancels the case, the record will be locked from editing by VR. However, the user is able to approve the record and status is changing from Cancelled to Closed. How do I avoid a user from approving/rejecting a case, when the status is in cancelled state?

4
  • How about another validation rule to check for PRIORVALUE and also closed state? Oct 31, 2018 at 21:24
  • @codeyinthecloud I don't think validation rules get triggered by Approval Processes Oct 31, 2018 at 21:29
  • @codeyinthecloud The VRs won't imply to the Approval process.
    – user61571
    Oct 31, 2018 at 21:31
  • My bad missed it! Oct 31, 2018 at 21:32

1 Answer 1

0

I think something like this trigger will help, although changes will be needed for your specific case:

for(Object obj : Trigger.New) {
        String oldStatus=Trigger.oldMap.get(obj.Id).Status__c;
        if(obj.Status__c== 'Closed' && oldStatus == 'Cancelled') {    
            isValid = false;
            obj.addError('Status cannot be changed from Cancelled to Closed');
    }
}
3
  • Hello Stas, Is there any declarative approach to restrict the user from approving/rejecting the case?
    – user61571
    Oct 31, 2018 at 21:32
  • @ShashN are you able to specify additional entry criteria for the Approval Process to verify that the Status is not equal to 'Cancelled' first? Oct 31, 2018 at 21:47
  • Yes. I did. I've also added extra criteria where if the checkbox is checked, then the approver related list wouldn't populate which serves the purpose. Thank you!
    – user61571
    Nov 1, 2018 at 14:52

You must log in to answer this question.