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

CNichols
Tera Contributor

The issue is surrounding the current.getLink() function. It returns a URL that goes directly to incident.do instead of nav_to.do?uri=incident.do. The experience for the client is a webpage that does not include the navigation menus on the top and left. The desire is to inject into what is returned by current.getLink() the nav_to.do so the navigation is returned.



Thoughts?


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.


this redirected back to the the incident with the nav. in it. so it did work



Thanks


Thank you for your response. But I still have a question. Is the only way to create the URL is manually? The problem with this is that I cannot capture this in an Updateset and any cloning of the instance would need to be updated to work in different instances. There has to be a way to this and prevent this type of issue.


I re-read your reply and now I see your entry for dynamically supplying the instance name. Of course this is after I came up with the following solution:



var link = current.getLink();


link = link.replace("instance.do?","nav_to.do?instance.do%3F")




Thoughts?