- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 06:11 AM
Hi
I'm new to scripting in ServiceNow but not new to ServiceNow as a product.
I want to introduce a Line Manager approval via email for all new Hardware and Software requests.
The Line Manager name entry is on an Order Guide we have as a variable. The variable is in a set and is global and cascaded.
I understand that I should be able to use the code in my workflow:
answer = [];
answer.push(current.variables.manager.sys_id);
answer.push(current.variables.div_dir.sys_id);
However this doesn't seem to work for me..... Can someone offer me some advice where I might be going wrong. We are on version Kingston.
Thanks in advance
Anita
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 10:11 PM
We are using workflow to manage all our approvals - including line manager (which we get from the user record) and other ones as needed - these values are all placed into variables.
Inside the workflow I use the 'Approval User' activity - and inside the activity I have checked 'advanced' and enter the below in the 'Additional Approvers Script':
answer = [];
answer.push(current.variables.u_line_manager);
Note: 'u_line_manager' is my variable name.
This works for all my approvals.
We are on Jakarta, so I haven't moved any of these to the 'flow designer' as yet.
Hope this helps.
Carl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 07:15 AM
My workflow runs now 🙂 in the log I have the following:
org.mozilla.javascript.EcmaError: "linemanager_approval_sw" is not defined. Caused by error in <refname> at line 2 |
So my script uses the sc_request table. How would I get the variable in to sc_request from an Order Guide.
Thanks
Anita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 07:21 AM
HI,
You have to query ritm attached to that REQ and then get the variable value from that ritm ticket and pass it to answer.push
reference script:
var mngr;
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request',current.sys_id);
gr.query();
if(gr.next())
{
mngr = gr.variables.variable_name;
}
answer.push(mngr);
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 07:02 AM
kindly refer the thread below. this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 05:12 AM
I just seem to get the error org.mozilla.javascript.EcmaError: Cannot read property "manager" from undefined.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 05:16 AM
what exactly have your written?
can you share the screenshot?