Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Steps to add cancelled condition to Approval User activity

Savitha Gururaj
Giga Contributor

Need help with adding a cancelled condition to an Approval User activity. I have the completed the following 3 steps but the workflow is not progressing to the Set Values activity even when the Approval User activity has a result of 'cancelled'.

1. Created a cancelled condition in the Approval User activity.

2. modified the condition for approval in the Approval User activity to Wait for : condition based on script with the following script:

if(approvalIDs){

if(approvalIDs['cancelled']){

      answer = 'cancelled';

}else if(counts.rejected > 0){

answer = 'rejected';

}else if(counts.approved > 0){

answer = 'approved';

}

}

3. Modified the KMC - Run parent workflows (Approval) business rule to add condition: ||   current.state.changesTo('cancelled')

find_real_file.png

find_real_file.png

Thanks!

5 REPLIES 5

Maybe try a different condition for approval script on your approval activity? This is the one that I use:



var cax = 0;


var a = new GlideRecord('sysapproval_approver');


a.addQuery('sysapproval',current.sys_id);


a.addQuery('u_approval_level','manager_approval'); //this is a custom field we use because we can do multiple types of approvals and I only want to check the approvals for this level


a.query();


while(a.next()){


      if(a.state == 'cancelled'){


              cax += 1;


      }


}


 



if (counts.approved > 0){


      answer = 'approved';


}


else if (counts.rejected > 0){


      answer = 'rejected';


}


else if (counts.total == counts.not_required){


      answer = 'not_required';


}


else if (counts.total == cax){


      answer = 'cancelled';


}