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?

  • How about another validation rule to check for PRIORVALUE and also closed state? – codeyinthecloud Oct 31 '18 at 21:24
  • @codeyinthecloud I don't think validation rules get triggered by Approval Processes – Stas Christiansen Oct 31 '18 at 21:29
  • @codeyinthecloud The VRs won't imply to the Approval process. – user61571 Oct 31 '18 at 21:31
  • My bad missed it! – codeyinthecloud Oct 31 '18 at 21:32
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');
    }
}
  • Hello Stas, Is there any declarative approach to restrict the user from approving/rejecting the case? – user61571 Oct 31 '18 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? – Stas Christiansen Oct 31 '18 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 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy