Service Catalogue variables into approval email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2022 07:27 AM
Hello Team,
I am trying to add a couple of service catalogue variables in an approval email notification.
I have reviewed multiple posts on this topic (see below some of them)
However, I was not able to achieve what I want.
I found out that there is an out-of-the-box script that should do the trick. The script name is "requested_items_summary_with_options" and this is how it looks like.
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 />");
}
}
}
I have replace the "set.setRequestID" with the sys_id of my cat item and injected the script in the notification, but it doesn't work.
The reason why it doesn't work is because (I assume) the script is designed to work with the sc_req_item table, but my notification works with the sys_approval table.
Any idea how I can add variables from a catalogue item into a notification that works with the sys_approval table?
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 06:59 PM
You can use if condition to check your variable like below:
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '' && vs.get(i).getLabel() == 'Variable Label/Question') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br />");
}
}
Thanks
Anil Lande