If a request is submitted by a manager, is it possible to bypass an approval in a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 02:16 PM
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.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 02:26 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 07:10 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 07:23 AM
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';
}
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade