- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:43 AM
I am trying to update the email notification "Email assigned to group (sc_task).
All fields are populated except for the "employee_name" which I'm trying to pull from the variables on the SCTASK itself.
This is what the body looks like:
${mail_script:sctask_subject_line}
Number: ${number}
Short description: ${sc_task.short_description}
Request Requested for: ${request.requested_for}
Employee Name: ${sc_task.variables.employee_name}
Assignment group: ${assignment_group}
Also, my subject line script isn't pulling any values at all.
This what the subject line looks like right now: Task undefined - undefined for undefined
This what I have for the script:
email.setSubject('Task '+current.sc_task.number.getDisplayValue()+' - '+ current.sc_task_short_description.getDisplayValue()+' for '+current.sc_task.variables.employee_name.getDisplayValue());
WHAT AM I DOING WRONG?
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:50 AM
HI,
Employee Name: ${sc_task.variables.employee_name}
variable is on RITM table. So try using this Employee Name: ${sc_task.request_item.variables.employee_name}
Thakns,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:50 AM
Hi Joe,
If notification is on sc_task table then you can use below directly.
email.setSubject('Task '+current.number.getDisplayValue()+' - '+ current.short_description.getDisplayValue()+' for '+current.variables.employee_name.getDisplayValue());
No need to use current.sc_task...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:50 AM
HI,
Employee Name: ${sc_task.variables.employee_name}
variable is on RITM table. So try using this Employee Name: ${sc_task.request_item.variables.employee_name}
Thakns,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 11:33 AM
Nice Ashutosh. Really helpful. I feel understanding of basic Datastructure of ServiceNow objects is very much essential. Once we visualize & understand the relationships, then we can easily manipulate the data.
Thanks,
Rahul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 08:56 AM
use below email script to get variable information
template.print("<b>Summary of Requested items:\n</b>");
var item = new GlideRecord("sc_req_item");
if (item.get(current.request_item.sys_id)) {
template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id); set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getDisplayValue() != '') {
template.space(4); template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}
}