Email notification link to Incident in ServicePortal view

edhefford
Kilo Expert

Hi Everyone,

When ServiceNow shoots an email to the customer after logging an incident, I am needing to include a link to the incident, but linking directly to the Service Portal view.

The email will be something like this...

Screen Shot 2017-06-15 at 10.56.41 am.png

I am currently linking them to our Service Portal page, and they have to find the ticket themselves.

If i use the URI_REF field in the email, it takes the user to the ServiceNow back end view, which we dont want users with no role to be able to see.

Is there any easy way to do this?

Any feedback or thoughts would be most appreciated.

Thanks,

Ed

1 ACCEPTED SOLUTION

Hi Michael.Fry,



Thank you for this link to the page, it worked perfectly upon creating the new script. Were you able to change the link in the email from displaying "Link" to something else?



For anyone else looking, dylanhasselquist provides the script below.



In our own instance I included Service Portal links by using an email notification script, the contents of which looks like:




  1. (function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,  
  2. /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,  
  3. /* Optional GlideRecord */ event) {  
  4.   var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">Link</a>';  
  5.   template.print(url);  
  6. })(current, template, email, email_action, event);  


I can then reference this in email notifications/templates by: ${mail_script:service_portal_link}



Note: The syntax highlighting looks a little off in the code snippet above, but you get the idea. I also replaced the name of our portal with "sp" to remain consistent with your example above.


View solution in original post

3 REPLIES 3

Michael Fry1
Kilo Patron

I used info from here to make my own: Portal hyperlinks via email


Hi Michael.Fry,



Thank you for this link to the page, it worked perfectly upon creating the new script. Were you able to change the link in the email from displaying "Link" to something else?



For anyone else looking, dylanhasselquist provides the script below.



In our own instance I included Service Portal links by using an email notification script, the contents of which looks like:




  1. (function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,  
  2. /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,  
  3. /* Optional GlideRecord */ event) {  
  4.   var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">Link</a>';  
  5.   template.print(url);  
  6. })(current, template, email, email_action, event);  


I can then reference this in email notifications/templates by: ${mail_script:service_portal_link}



Note: The syntax highlighting looks a little off in the code snippet above, but you get the idea. I also replaced the name of our portal with "sp" to remain consistent with your example above.


sorry Michael.Fry, ignore that last message, me not reading the entire script



Cheers,



Ed