url incident redirect

reyservicenow
Tera Expert

When a user receives an email notification that an incident has been assigned to their group, the link that takes you to the incident does not include the full ServiceNow navigation but only the incident window.

1 ACCEPTED SOLUTION

This is a link to an incident which preserves navigation ( note: I randomized the sys_id   in this example)


https://YOUR_INSTANCE_HERE.service-now.com/nav_to.do?uri=incident.do?sys_id=0dd233df0a234c7e00f3fe1f...



This is a link to an incident which does not preserve navigation:


https://YOUR_INSTANCE_HERE.service-now.com/incident.do?sys_id=086893c70a0a3c7e0060fe80d534506f



Here's a quick guess as some code that might help:



*** Warning: untested code follows.   Use at own risk ***



Replace


var link = current.getLink();



With


var link = "https://YOUR_INSTANCE_HERE.service-now.com/nav_to.do?uri=incident.do?sys_id=" + current.sys_id.toStr...



EDIT: Adding advice to allow this solution to adapt to the instance where it may run.   Instead of hardcoding the instance name in the URL, you can obtain it from the system property "instance_name".   There is a reference for how to do this at GlideSystem - ServiceNow Wiki  



It basically would go like this, replace the initial statement with these: ( caveat: untested code follows )



var instance = gs.getProperty('instance_name');


var link = "https://" + instance + ".service-now.com/nav_to.do?uri=incident.do?sys_id=" + current.sys_id.toStrin...




NOTE: Email notifications should be included in update sets.   If it's not there, maybe there's a problem with your "Application Scope".   Out of the box notifications are probably in the global scope.


View solution in original post

15 REPLIES 15

its an email script:




(function runMailScript(current, template, email, email_action, event) {


  var link = current.getLink();


  if (email_action.name != "Incident Resolved") {


  template.print('<p><font size="3" color="#808080" face="helvetica">');


  template.print(gs.getMessage('You can view all the details of the incident by following the link below') + ':');


  template.print('</font></p>');


  }


  else {


  template.print('<p><font size="3" color="#808080" face="helvetica">');


  template.print(gs.getMessage('If you feel the issue is not resolved, please click the following link and reopen your incident') + ':');


  template.print('</font></p>');


  }


  template.print('<font face="helvetica">');



  var backgroundColor = 'background-color: #278efc;';


  var border = 'border: 1px solid #0368d4;';


  var color = 'color: #ffffff;';


  var fontSize = 'font-size: 16px;';


  var fontFamily = 'font-family: Helvetica, Arial, sans-serif;';


  var textDecoration = 'text-decoration: none; border-radius: 3px;';


  var webKitBorder = '-webkit-border-radius: 3px;';


  var mozBorder = '-moz-border-radius: 3px;';


  var display = 'display: inline-block;';


  var padding = 'padding: 5px;';



  if (email_action.name == "Incident Survey") {


  color = 'color: #343d47;';


  backgroundColor = 'background-color: #e6e8ea;';


  border = 'border: 1px solid #bdc0c4;';


  }


  template.print('<a href="' + link + '"');


  template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);


  template.print('">');


  template.print(gs.getMessage('Take me to the Incident'));


  template.print('</a>');


  template.print('</font>');


  template.print('<br><br>');


  template.print('<p><font size="3" color="#808080" face="helvetica">');


  template.print('Thank you.');


  template.print('</font></p>');


})(current, template, email, email_action, event);


[EDIT] All joking aside, this is a prime candidate for an update to use the OOB tools.


I don't have time to dissect/make sense of all the code but you can to ALL of that without coding a single character.


the issue is that this was do-able before in like eureka i did this back then but now with helsinki the current version i am on they have changed it to to a link.do so let me try what steve said


Rey, I apologize. I understand that my post while in jest, was in poor form.


I can't send you a PM to apologize because you're not following me, so I'll say it publicly.



In the future, you can save yourself a lot of headache by doing all of that in the normal notification engine--If you want to Reopen via email, you can use a mail template to spawn a new email, with a pre-set subject line (like email-based approvals), all the HTML can be done in the WYSIWYG editor, and you won't have to worry (as much) about stuff breaking on upgrades.


Find the offending email notification (like Steve mentions) and check the "Message HTML."



Add in the desired link type-- ${URI} or ${URI_REF} and you should be on your way.