- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 09:09 AM
I have created a workflow that has a notification being sent. But it seems to not be in the right format because it is not copying the variables over. Here are some of the variables. Can someone help with the script part?
Here some of the variables, if someone help me get started i can finish it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 01:49 PM
This is a preview of a notification in the notifications section of ServiceNow. Also it looks like it is pointing to the sc_task table when it need to be on the sc_req_item table. In the email logs did you try clicking Preview HTML Body related link.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 09:23 AM
In this case, you would need to use ${current.variables.yourVariableName} whenever you wanted to call them in the notification. If that workflow currently is tied to the catalog item in question, you can use that Fields dot-walking box to get to them as well. (Click the +, then go down to variables and find the one you need, assuming that workflow is ran from the Requested Item or such table.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 10:28 AM
Ok I will try this Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 10:49 AM
Here is a mail script I use to send out all the filled out variables on a Requested item. So if a variable is not mandatory and was not filled out it will not be sent. Hope this helps.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
template.print("Summary of Requested item:\n");
var task = new GlideRecord("sc_task");
var sc_number = '';
task.addQuery('request_item', current.sys_id);
task.query();
if (task.next()){
sc_number = task.number;
}
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.sys_id);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.cat_item.getDisplayValue() + "\n");
template.print("Task Number: " + sc_number + "\n");
template.print(" Item Options:\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");
}
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 10:53 AM
Should this be added to the workflow notification or should I create an event and a separate notification?