- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 10:53 AM
Hello everyone!
We have several workflows with multiple approval levels. We are trying to work on a solution if a user exist in level 1 approval and level 2 approval then the level 2 should be auto approved and move the workflow to next stage. is there anyway to achieve this scenario?
(The reason behind this is, if a user receives two approvals level1 and level2 he approves level1 approval and he forgets that he has another approval pending and now the workflow doesn't moves to next stage)
Thank you in advance.
Karthik
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 02:30 PM
I don't have any code, I just tried to verify it with empty answer (answer = [];)
What I would do is:
1. Define sysIDs of approvers (separated by commas) in some system property so you don't need to touch the WF once it is set
2. Write the script something like this:
var answer = [];
var approvers = gs.getProperty('myPropertyWithSysIDsOfSecondApproval');
var firstApproversArr = approvers.split(',');
var currentID = current.getUniqueValue();
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval', currentID);
approvalGR.addQuery('state', 'approved');
approvalGR.query();
while (approvalGR.next()) {
for (var i = 0; i < firstApproversArr.length; i++) {
if (approvalGR.getValue('approver') == firstApproversArr[i]) {
return answer;
}
}
}
answer = firstApproversArr;
I haven't tested it so it may need some tweaking

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 12:53 PM
Please mark my answer as helpful / correct if it solved your issue to make it easier to identify the solution to others dealing with same issue. Thanks