- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 02:37 AM
Hi All,
I have created a notification on user table so when a new user is created it should trigger notification to a department head to add few more details and i have provided the link in the notification that link will redirect to service portal and opens a catalog item. But i want to add it dynamically when we move the code to different intance also it should work.
Notification detalis
When to send : Record Inserted
Who will recieve : department head
What it will contain: http://details.about.thelink. It will resirect to portal.
Please suggest how can i achieve this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 02:42 AM
Hi Tejaswini,
You can simply pass it as below.
Where sp is my portal name & sys_id is sys_id of item which ideally will be same across instances thus making it dynamic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 02:47 AM
Instead of hardcoding the instance name your email notification, use gs.getProperty('glide.servlet.uri') to dynamically grab the URL of the current instance.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 02:48 AM
Hi,
If you are giving the link in message body then check what Jaspal has mentioned about relative URL
If it is in email script then you can use this to get the instance name
var instanceName = gs.getProperty('instance_name') ; // this would give you instance name
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 03:02 AM
Relative URLs in notifications will not work, cause those end up displayed in an e-mail client - where there is nothing to be relative to, or in a browser where it will be relative to the current page (e.g. google.com or yahoo.com).
You need to create a mail script and build the URL in script, using
E.g:
template.print(gs.getMessage('https://{0}.service-now.com/{1}', [gs.getProperty('instance_name', 'example'),
'sp?id=...']));