Email Notifications Pulling Catalog Item Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have a request to add more details to the emails that send out from ServiceNow. What I would like to do is add the variables on each Catalog Item in the body of the email that gets sent out.
We currently have an email that sends out that gives generic info. e.g. RITM number, Title, Opened BY, and Validation group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
41m ago
If you had to consider all variables in all forms would make it clumpsy and also, the formats wouldnt match, some would be as reference values, choice values, true false etc. It wouldnt work as expected considering the Catalog UI policies, catalog client scripts etc. Sometime unnecessary fields pop-up and cause a lot of confusions. Users would start seeing fields they never filled up etc.
I would recommend to target high volume or sensitive items as a start and define the variables based of your UI policies and selections and populate in description or an unused field and add that field to the notification.
This way you will not make huge changes, and target as things go. You can include this in your dev handbook to update this field whenever there is a new item, change in a flow/workflow/item. It might be a slow start, but would be a clean way of addressing it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
33m ago - last edited 31m ago
If you don't want to use variable one by one in the notifications such as ${variables.test1} , you will need to create an Email Script [sys_script_email], e.g.
Name : get_ritm_variables
Script:
(function runMailScript(current, template, email, email_action, event) {
var gr = new GlideRecord('sc_item_option_mtom');
gr.addQuery('request_item', current.sys_id);
gr.query();
if (gr.hasNext()) {
template.print('<h3>RITM Variables:</h3>');
template.print('<table border="1" cellpadding="5" cellspacing="0">');
template.print('<tr><th>Variable</th><th>Value</th></tr>');
}
while (gr.next()) {
var question = gr.sc_item_option.item_option_new.question_text;
var value = gr.sc_item_option.value;
template.print('<tr>');
template.print('<td>' + question + '</td>');
template.print('<td>' + value + '</td>');
template.print('</tr>');
}
if (gr.getRowCount() > 0) {
template.print('</table>');
}
})(current, template, email, email_action, event);and call it from the Notification body (Message HTML field on [sysevent_email_action]:
${mail_script:get_ritm_variables}
Indeed, to be used with caution not to set all variables visible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
28m ago
Nice one, if there are not much complications in the variables and their visibility in most of the catalogs, it should be doable. We could also consider to include multi-row if its available.
In the long run, it should be easily maintainable. One would be aware of their environment to take a call.
