- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Included in the Developer Toolbox Update Set available on Share (link to Share in the post).
Here's a replacement for the "Show Notification Scripts" UI Action on the Notification form. It's a Relationship record that allows you to add a Related List to the bottom of the Notification form to display the Email Scripts that are referenced from within the Notification:
To add it, create a new Relationship record (System Definition \ Relationships) with the following details:
Name: Email Scripts
Applies to table: Notification [sysevent_email_action]
Queries from table: Email Script [sys_script_email]
Query with:
(function refineQuery(current, parent) {
//Written by Jim Coyne
//https://community.servicenow.com/community?id=community_user_profile&user=8352da29dbd81fc09c9ffb651f9619c7
//https://community.servicenow.com/community?id=community_blog&sys_id=be8c3d7adb4b5fc4a39a0b55ca9619f3
//allows admins to see a list of Email Scripts referenced in a Notification record
//the "Email Scripts" Related List must be added to the Notifications form
var mailScript = [];
var names = [];
var query = "sys_id=-1"; //default so no records are returned/shown
//get the contents of the Message or Message HTML field
var message = "";
if (parent.sys_version == 2) {
message = parent.getValue("message_html");
} else {
message = parent.getValue("message");
}
//find any script names within the message
var regex = /\$\{mail_script:(.[^}]*)?\}/g;
while ((mailScript = regex.exec(message))) {
names.push(mailScript[1]);
}
//create the query if any script names were found
if (names.length > 0){
query = "nameIN" + names.join(",");
}
//get the list of scripts based on what was found in the message field
current.addEncodedQuery(query);
})(current, parent);
Once you create the record, add the Related List by right-clicking the form header and selecting "Configure \ Related Lists" menu item and move the "Email Scripts" item from the "Available" box over to the "Selected" box and click "Save". You will want to add it to both the Default and Advanced views.
If you want to remove the "New" button, right-click a list column header and select the "Configure \ List Control" menu item and check the "Omit new button" checkbox and then click the "Update" button.
The nice thing about this approach is you can see the Email Scripts being referenced in the Notification without being taken away to another window.
I've attached an XML file for the Relationship record so you can just import it into your instance. As always, try it out in your company's development instance first, or better yet, your own personal development instance.
- 1,740 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.