Link email notifications to portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2020 10:49 AM
I am working on notifications for our end users and wanted to start having them point to the portal. I did some researching and found this post: https://community.servicenow.com/community?id=community_question&sys_id=79d187a9db98dbc01dcaf3231f961933
However I am seeing two problems with this and wasn't sure how to fix them:
1. I wanted to use it for two different portals - we have an internal portal and a client facing portal. How do I make sure it works for the appropriate link?
2. When I put the script into my instance I got the error: Email script render error: email script [ service_portal_link ] does not exist
Any ideas on how this one?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 09:11 AM
Thanks Asif!
We do have a redirect for a portals but when I was testing it, it looks like it still goes to the same portal regardless of who is logged in.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 09:21 AM
Not sure if this is helpful but here is what I started to do to the email script:
if(recipient_user.email.toString().indexOf('INTERNAL EMAIL ADDRESS')){
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">${number}</a>';
template.print(url);
})(current, template, email, email_action, event);
}
else { (function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 't?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">${number}</a>';
template.print(url);
})(current, template, email, email_action, event);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 10:04 AM
Hi,
use this:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
if(recipient_user.email.toString().indexOf('INTERNAL EMAIL ADDRESS')){
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">${number}</a>';
template.print(url);
}else{
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 't?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">${number}</a>';
template.print(url);
}
})(current, template, email, email_action, event);
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 11:05 AM
I tried this and it is not showing the number now; almost like it's no longer referencing the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 12:10 PM
Hi,
Can you show the script?
Thanks,
Ashutosh