The CreatorCon Call for Content is officially open! Get started here.

Auto approve if the user exists more than once in the workflow

Karthikpasikant
Tera Guru

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

1 ACCEPTED SOLUTION

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

View solution in original post

5 REPLIES 5

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