Adding an 'Unsubscribe' link to an email message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2009 10:08 AM
Hello,
I wanted to know the NOTIFICATION_MESSAGE_SYS_ID in the link. What is it? Email Notification sys_id?
template.print('' + 'Unsubscribe' + '\n');
Please help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2009 12:48 AM
Kindly help me with what should be put here in place of NOTIFICATION_MESSAGE_SYS_ID:
template.print('' + 'Unsubscribe' + '\n');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2011 12:29 PM
That field needs the sys_id of the Email Notification (sysevent_email_action) you want to unsubscribe from.
However hardcoding this can cause problems when moving instances, and will not work in templates.
If you use the email script below, it will automatically grab the notification sys_id and instance URL. This comes in handy when you move from dev to test to prod, and you can just copy paste this in the body of any email notification (or template) and you don't have to hard code the sys_id of the notification.
<mail_script>
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + 'unsubscribe.do?sysparm_notification=' + email_action.sys_id + '">Click here to Unsubscribe</a> from the "' + email_action.name + '" Notification<br />\n');
</mail_script>
The
gets the 'glide.servlet.uri' system property which contains the full URL for your instance, https://yourcompany.service-now.com/
gs.getProperty('glide.servlet.uri')
the
object is available in mail scrits and contains the GlideRecord for the Email Notification (sysevent_email_action) that is generating the current email.
email_action
When a user clicks this link it runs the code on the UI Page 'unsubscribe' which then grabs the Notification sys_id we stuck in the url, and adds a filter to the Notification Preference for the current user for that notification, which unsubscribes them.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2013 06:50 AM
I've set this up on my calgary instance and it appears that the unsubscribe link is only working for users that are in the admin role. I have ITIL users that can go to my profile and unsubscribe to the notification, but when they click the email link, it will not unsubscribe. If I change the itil user to have the admin role it works.
I'm using the code:
template.print('Click here to Unsubscribe from the "' + email_action.name + '" Notification
\n');
the notification I'm using to test with is incident opened for me, and it's not set to mandatory. Is there a way to make this work with itil users or even a user with no role that gets emails?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2017 07:22 PM