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

SanjivMeher
Kilo Patron
Kilo Patron

You should find the solution in below thread



Approval not following cancelled output



Please mark this response as correct or helpful if it assisted you with your question.

Thank you for the response.



I had already followed the steps in the article. The one change I made in the workflow is in the 'wait for condition' script to use the following log statement as suggested in the article.


gs.log(' total: ' + counts.total + '\napproved: ' + counts.approved + '\nrejected: ' + counts.rejected +   '\nrequested: ' + counts.requested + '\nnot_requested: ' + counts.not_requested + '\nnot_required: ' + counts.not_required);  



and the log output is:



total: 1


approved: 0


rejected: 0


requested: 1


not_requested: 0


not_required: 0



I am not sure how but the count is set for requested to 1 and I don't see cancelled here. I was checking for approval to be cancelled but now wondering if it should be changed to requested but why?



if(approvalIDs){


if(approvalIDs['cancelled']){


    answer = 'cancelled';


}else if(counts.rejected > 0){


answer = 'rejected';


}else if(counts.approved > 0){


answer = 'approved';


}


}


In this business rule, did you try adding, current.state.changesTo('cancelled')?



find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

Savitha Gururaj
Giga Contributor

Yes, I have added the condition to the Business Rule and also logging the current.state. The bus. rule is getting executed. The result of the Approval activity is getting set to cancelled. But the workflow is not progressing to the next step.   I have followed every step mentioned in this article: https://old.wiki/index.php/Custom_Transitions_for_the_Approval_-_User_Activity but with no luck so far.






find_real_file.png


find_real_file.pngfind_real_file.png