How to Skip Service Catalog Approval if Manager is opening a Request Item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 05:35 AM
I am working to modify our existing on-boarding Catalog form. Here on our form we have field called "Manager (Employee's direct supervisor).
What I am looking for is when a manger himself is opening a request then it should skip the Service Catalog Approval process and create a task , Otherwise if request is opened by someone else it should trigger approval process to manager mentioned in "Manager " field. In order to achieve this i have tried below mention script but somehow it skipping the approval in both scenario, when raised by manager or by others.
answer = ifScript();
function ifScript() {
var manager = current.variables.nh_manager;
var openedBy = current.opened_by;
if (manager == openedBy) {
return 'yes';
} else{
return 'no';
}
}
On - Boarding form example
Variable name of Manager field
Can anyone help what I am missing to achieve the desired results. I am new to ServiceNow so my scripting not that advance.
Thanks & Regards,
Naresh
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 06:00 AM
Hi Naresh - Try putting some log messaged in your script, then checking System Logs for the output. You can easily do something like the following to get a better idea of what might be going wrong. in the system Log look for messages starting with TMP to see what you're getting for values in those fields.
answer = ifScript();
function ifScript() {
var manager = current.variables.nh_manager;
var openedBy = current.opened_by;
gs.log('TMP - MANAGER: ' +manager);
gs.log('TMP - OPENED BY: ' +openedBy);
if (manager == openedBy) {
return 'yes';
} else{
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 06:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 08:17 AM
hi Naresh - It looks like the values are there. They are the sys_ids of the 2 fields.
You might try moving your variable declaration before the function
var manager = current.variables.nh_manager;
var openedBy = current.opened_by;
answer = ifScript();
function ifScript() {
if (manager == openedBy) {
return 'yes';
} else{
return 'no';
}
}
and/or converting the values to a string:
var manager = current.variables.nh_manager.toString();
var openedBy = current.opened_by.toString();
answer = ifScript();
function ifScript() {
if (manager == openedBy) {
return 'yes';
} else{
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 08:33 AM
Try this
answer = ifScript(); function ifScript() { var manager = current.variables.nh_manager.toString(); var openedBy = current.variables.opened_by.toString(); if (manager == openedBy) { return 'yes'; } else{ return 'no'; } }
Please mark my response as correct and helpful if it helped solved your question.
-Thanks