If a request is submitted by a manager, is it possible to bypass an approval in a workflow

Marc43
Kilo Expert

i am wondering if there is a way to bypass a manager approval stage in a workflow if the request is submitted by the manager. For example, if the manager opens the request, is listed as the requested by is a report of their's, it would bypass any approval request and generated. 

3 REPLIES 3

Maverick E
Tera Guru

Hello Marc,

You can by-pass approvals in the workflow by adding an If activity in the workflow and adding this script:

var ourUser = gs.getUser().getUserByID(current.opened_by); 

answer = ifScript();

function ifScript() {
    if (ourUser.isMemberOf('groupname')) {
        return 'yes';
    }
    return 'no';
}

 

If it returns yes, then have the activity direct them to a path that skips the approvals.

Make sure to replace the groupname with the managers group.

It looks like this would work for a group approval, but this request has the manager set by a variable named 'manager' and is not set as a group approval. 

What we will need is that if the variable named 'requested_by' is set the same as the variable 'manager' then it bypasses the manager approval and opens the task directly. 

AbhishekGardade
Giga Sage

Hello Marc,

1. You can add IF activity after start and check if the person who submits a request is a manager or not.

2. In IF activity add below code: 

// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.

answer = ifScript();

function ifScript() {
var mgr = current.variables.requester; // replace your variable name or requestor field
var gr = new GlideRecord('sys_user');
gr.addQuery('manager',mgr);
gr.query();
gs.print("CNT:"+gr.getRowCount());
if(gr.next()){
return 'yes';
}else{

return 'no';

}
}

find_real_file.png

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

 

 

Thank you,
Abhishek Gardade