I want to display all catalog variables on notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 03:35 AM
Hi Team,
I want to display the variable in notification which is available on the catalog form, i will create the notification on sc_task table, before that Can anyone suggest the sample email script here. Assume variable name is "requestor".
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 03:39 AM
I have this mail script which will help you to display all variables.
var vquest;
var variables = current.variables.getElements();
for(var key=0;key<variables.length;key++) {
vquest = variables[key].getQuestion();
template.print("<p style=\"margin: 0in 2.85pt 0.0001pt 20pt;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #585856;font-size: 11pt;\"><strong><span style=\"color: #00205b;\">" + vquest.getLabel()+ "</span></strong> " + vquest.getDisplayValue() + "<br /></span></p>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 04:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 04:34 AM
Hi Sunitha,
You need to write the script provided by Harshad in email notification script
and in the notification body you can call that script like : ${mail_script: name_of_your_script}
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2022 05:00 AM
Hi,
you can create email script and then use something like this and include that email script in email body
I assume you know how to create email script and include in email body
Mail script: print_cat_item_request_submitted
Script:
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('Variable Summary: <br/>');
var ritm = new GlideRecord('sc_req_item');
ritm.get('sys_id', current.request_item);
var variables = ritm.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != '' && value != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader