- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2020 11:50 PM
Hi All,
I just want to check if anyone here had implemented something similar to my requirements. I wanted to setup an approval in the workflow that dot walks from the requestor's manager's manager that is dependent on the Title of the manager. The approver will only be added if the Titile startswith D - or MD - [which stands for Director or Managing Director]. So for example I raise a request but my manager is not D - or MD - level, then it will bypass my manager then will dotwalk to my manager's manager and check the Title and will only be added as approver only if the title is satisfied. Sounds bizarre but that is the requirement we have.
If anyone has similar to this, can you share the approval script that you have used and how its done.
Thanks in advance.
Ramel
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 12:02 AM
Hi Ramel,
you can use if activity in workflow to determine whether approval is required or not
Sample script below
answer = ifScript();
function ifScript(){
// I assume you are using requested_for field on RITM
var managerTitle = current.request.requested_for.manager.manager.title; // dot walking 2 times
if(managerTitle.startsWith("D-") || managerTitle.startsWith("MD-"))
return 'yes';
else
return 'no';
}
the output of yes would take to the next User Approval Activity
the output of no would take to next step and skip approval Activity
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 12:01 AM
1. uncomment answer variable in the advanced script which is already available in user approval activity.
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',current.requested_for.manager);
gr.addEncodedQuery('titleSTARTSWITHD -^ORtitleSTARTSWITHMD -');
gr.query();
if(gr.next())
{
answer.push(gr.sys_id);
}
else{
var gre= new GlideRecord('sys_user');
gre.addQuery('sys_id',current.requested_for.manager.manager);
gre.addEncodedQuery('titleSTARTSWITHD -^ORtitleSTARTSWITHMD -');
gre.query();
if(gre.next())
{
answer.push(gre.sys_id);
}
}
In above script the reference is made to "requested_for" if you are using a catalog variable change it to current.variables.requested_for
Pls. mark this correct/helpful, if applicable.
Thanks.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 12:02 AM
Hi Ramel,
you can use if activity in workflow to determine whether approval is required or not
Sample script below
answer = ifScript();
function ifScript(){
// I assume you are using requested_for field on RITM
var managerTitle = current.request.requested_for.manager.manager.title; // dot walking 2 times
if(managerTitle.startsWith("D-") || managerTitle.startsWith("MD-"))
return 'yes';
else
return 'no';
}
the output of yes would take to the next User Approval Activity
the output of no would take to next step and skip approval Activity
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 12:04 AM
you can use here if activity before the approval activity , where you will check the requester manager manager title and bases on that you will set the if activity transition
eg:
answer = ifScript();
function ifScript() {
var rd = current.request.requested_for.manager.manager.title.getDisplayValue()
if (rd.startsWith("D") || rd.startsWith("MD")) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2020 01:00 AM
thanks all for the response, appreciate it. I've decided to use the if condition check 🙂