How to get the current notification value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 02:00 AM
Hi all,
I need a way to query if the current record the notification is working of off, matches the notification selected in the ticket.
i.e. INC0000001 has the customer facing template selected (via a reference field), and the event that notification is build on is triggered.
I need all the notifications running against that trigger to check if that notification is the one set in the ticket, answering true if so.
Once I can get hold of the notification I can see if it matches, without having to register numerous event names.
answer = (current.getUniqueValue() === this.getUniqueValue()) ? true : false;
But getting the keys of 'this' doesn't reveal anything obvious to use.
Any way of getting the notification object/sys_id from within the notification script?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 02:13 AM
The unsubscribe link uses email_action.sys_id to identify a notification (or email_action.name for it's title)
template.print('<a href=""' + gs.getProperty('glide.email.override.url') + '?uri=unsubscribe.do?sysparm_notification=' + email_action.sys_id + '"">Click here to Unsubscribe</a> from the ""' + email_action.name + '"" Notification<br />\n');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 02:27 AM
Mmm promising, and good to know for future, but email_action isn't available in the notifications.
Of the below, only the 1st line will print to the log...
gs.log("RP test pre");
gs.log("RP email_action.sys_id "+email_action.sys_id);
gs.log("RP email_action.sys_id "+email_action);
gs.log("RP test post");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 02:34 AM
looks like it has to be inside that <mail_script> enclosure to work, so that's probably not going to be any good to you?
I found this discussion on a previous thread here:
https://community.servicenow.com/thread/148987
- <mail_script>
- //get the sysevent_email_action record
- gs.log("email_action.getUniqueValue() = " + email_action.getDisplayValue() + " : " + email_action.getUniqueValue(), "EMAIL");
- //get the sysevent record that fired this notification
- gs.log("event.getUniqueValue() = " + event.getDisplayValue() + " : " + event.getUniqueValue(), "EMAIL");
- </mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 04:45 AM
Oh sorry think I need to be clearer; I need to get the value in the condition script section.
That way I can control whether the notification runs or not.