How to display catalog item variable input in email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 07:04 AM
Hi All,
We have a catalog item and need to create a email notification such that notification show the input present in variable field .
Like : email notification show "my_name" & "reportee" in email notification
Kindly advise.
Regards,
B
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 07:08 AM
Hi @Bijender
Please refer below link for your solution:
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 07:10 AM
Hi,
Create a notification script and include it in your email, here is a notification script i created a while back to include all non empty variables form a ritm in an email
(function runMailScript(current, template, email, email_action, event) {
template.print('Variables: <br/>');
var variables = current.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if (value != '') {
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 07:13 AM
Hi @Bijender
You can create a mail script by navigating to System Notification->Email->Notification Email Scripts. You have to call that from your email notification using "${mail_script:<email_script_name>}
To display particular Variables, you can use below code in email Notification:
template.print('My variable name is '+current.variables.<variable_name>). // Replace <variable_name> with your variable name
To display all variables of that Catalog Item, can use below script:
for (var key in current.variables) {
var v = current.variables[key];
template.print('\n' + v.getGlideObject().getQuestion().getLabel() + ": " + v.getDisplayValue() + " <br />");
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 07:15 AM
Hi @Bijender ,
You can mentioned your variables in HTML notification as below :-