- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 02:28 PM
Hello all,
We have a catalog item that does not have a Description field when a user is completing the request so when the email notification 'Request Opened on your Behalf" is triggered, the description in the email body is blank. The same goes for when the email notification for the associated task is triggered since the description field is blank.
We would like to see if there is a way to add the catalog item variables (fields from the original request) onto the email notification so the user receives useful information.
I was able to achieve this by adding the variable names onto the message html for the email notification, but since this is something we want to accomplish across multiple catalog items I would like to see if there is a generic script I can use.
Below is what I currently tested:
Thanks in advance!
Grace
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 03:30 PM
Hi Grace,
There's an OOB script called 'requested_items_summary_with_options' in the Notification Email Scripts:
template.print("Summary of Requested items:<br />");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.cat_item.price.getDisplayValue() + " each <br />");
template.print(" Options:<br />");
var keys = [];
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).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br />");
}
}
}
Set your item sys_id in the set.SetRequestID line. This will fetch the variable names with their answer, you can modify it as needed.
Once you've modified it, you can add this email script to your notification body by adding ${mail_script:requested_items_summary_with_options} to it.
Hope this helps!
Yeny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 03:30 PM
Hi Grace,
There's an OOB script called 'requested_items_summary_with_options' in the Notification Email Scripts:
template.print("Summary of Requested items:<br />");
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sysapproval);
item.query();
while(item.next()) {
template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + " at " + item.cat_item.price.getDisplayValue() + " each <br />");
template.print(" Options:<br />");
var keys = [];
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).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br />");
}
}
}
Set your item sys_id in the set.SetRequestID line. This will fetch the variable names with their answer, you can modify it as needed.
Once you've modified it, you can add this email script to your notification body by adding ${mail_script:requested_items_summary_with_options} to it.
Hope this helps!
Yeny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 04:29 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 04:47 PM
Hi,
You wouldn't do item.3453453453574345
you would replace it with the sys ID entirely, so its just set.setRequestID(3453453453574345); That makes it hard coded for the item (not sure if this is intended)
On the other hand, leaving item.sys_id is dynamic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 08:38 AM
Thanks Darius for the correction but now that I tried just the sys_id, I kept getting an error that I had an extra number (see below). I tried it without the number and it didn't work so I think my error might be that I'm not using the correct sys_id?
I got the sys_id by going to Maintain Items > Data Jack catalog Item > Clicking the hamburger drop down menu > Copy sys_id
Thanks,
Grace