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-07-2022 07:33 AM
Hi,
Can you please your screenshot of email notification record (Containing Table and What it will contain part)
Also would need your email script, once we know email configuration then it would be easy to suggest changes.
Have you tried adding logs in email notification? Is your email script being called from notification?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2022 08:58 AM
Hi,
here is the email script. I have replaced the sys_id of my item with xxx.
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(XXX);
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 />");
}
}
}
here is the email notification
here is where I am trying to call the email script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2022 09:07 AM
I'm a little late to the party, but adding my 2 cents here.
Replace line 3 in your main script:
item.addQuery("request", current.sysapproval);
to
item.addQuery("sys_id", current.sysapproval);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2022 11:59 PM
Hi @AnirudhKumar,
your suggest did something indeed. This is what I get now.
Still, this is not what I am trying to achieve.
I need a couple of variables that I defined in the catalogue item.
Thank you.