Script for manager approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2019 10:25 PM
I am trying to write to manage approval script in which if a manager raises a request on behalf of his/her reportee then it should skip the manager's approval who is raising it and instead it's approval should go Manger's manager.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 10:34 AM
Check if the 'Requested By' is the same value as the 'Requested For's manager. You can dot walk in the script. If it is, then take the 'Requested by' and send the approval to that user's manager.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 10:34 AM
1) how do you know who the manager's reportees are?
2) how do you know who the manager's manager is?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 10:36 AM
You need an If activity before your approval to check for the manager. If the user is in a variable on your item, it would look something like this:
answer = ifScript();
function ifScript() {
if(current.variables.user_variable.manager == current.request.requested_for) {
return 'yes';
} else {
return 'no';
}
}
Then if yes, skip the approval and go to the managers manager approval

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 10:40 AM
You need a Run script activity in your workflow , just before the approval activity.
The script should be
if (current.variables.requested_for.manager == current.opened_by)
workflow_scratchpad_approver = current.opened_by.manager;
else
workflow.scratchpad.approver = current.opened_by;
Then use the workflow.scratchpad.approver in your approver-user activity to set approval
Something like answer = workflow.scratchpad.approver;
Please mark this response as correct or helpful if it assisted you with your question.