${URI_REF} is not going to the direct record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 01:06 PM
Hello,
I'm working on creating an email notification to trigger when a user gets mentioned in the activity stream. However, when I use ${URI_REF} and I preview the notification it list the Document ID and takes me to this page.
How am I able to fix this to take the user to directly to the record they were mentioned in?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 10:19 PM
Hi,
Yes, the url I added was wrong. Should have said incident:
template.print('<a href=nav_to.do?uri=incident.do?sys_id=' + current.document_id + '">LINK</a>');
For this error
Email script render error: email script [ redirect_to_incident ] does not exist
check what you named the script and add the exact name to the mail_script.
If the mail_script says: ${mail_script:redirect_to_incident}, make sure your script is called redirect_to_incident.
Also, if you copy-pasted the name, delete it and write it manually. No spaces etc. Might be that some HTML tag was inserted there and you're not seeing it.
As for dynamically creating the link, then yes.
The script should take the source table into account:
//This part should work for any oob table extending the Task table, for instance
var sourceTable = current.table;
var gr = new GlideRecord(sourceTable);
gr.get(current.document);
var recNum = gr.number;
template.print('<a href="nav_to.do?uri=' + sourceTable + '.do?sys_id=' + current.document + '">' + recNum + '</a>');
The result should be like this:
You might need to play around with it, exclude a table or disregard the lines that create the number and just add "LINK" instead, but that should do the work, mainly.
Hope it helps.