Blog

Top Navigation Buttons (Geneva)

This customization adds more functionality from the top menu in ServiceNow. You can add few buttons to help direct people to important ServiceNow applications.

Thanks to Russell Miller on the forums for helping get it working in Geneva.  I just added on to his idea and gave it a different design. I know, how original. :)

 

UI Script: Top Navigation
Global: true
Script:

document.addEventListener("DOMContentLoaded", function(event) {
 var theWindow = getTopWindow().window.location;
 var theURL = theWindow.href;
 if (theURL.indexOf('nav_to.do?') != -1 || theURL.indexOf('navpage.do') != -1 || theURL == baseURL) {
var theLinkElement = getTopWindow().document.querySelector("a[class~=headerlink]");
//Only insert if the user has roles and the links are not on the page already
if (g_user.hasRoles() && jQuery(theLinkElement).length == 0) {
 var theStyle = "float: right; padding:0px;font-size: 1.3rem; margin: 5px 0px 0px 0px;" +
"width: auto; height: 2px; text-align: center;" +
"color: white";

 //Common styling using div & spans
 var linkDivOpen = '<div><span style="' + theStyle + '">';
 var linkDivClose = "</span></div>";

 //Links
 var essLink = "<a target='_blank' href='/ess' id='essLink' class='headerlink' style='color: inherit;text-decoration: none;border: 2px solid white;border-radius: 3px;padding:8px;margin-right:10px'><span class='btn btn-icon icon-cart' style='font-size: 20px;' />Self Service</a>"; //);
 var sneLink = "<a target='_blank' href='http://www.servicenowelite.com' id='sneLink' class='headerlink' style='color: inherit;text-decoration: none;border: 2px solid white;border-radius: 3px;padding:8px;'><span class='btn btn-icon icon-lightbulb' style='font-size: 20px;' />ServiceNow Elite</a>"; //);

 var theHeaderElement = getTopWindow().document.querySelector(".nav.navbar-right");
 //Insert the links
 jQuery(linkDivOpen + essLink + linkDivClose).insertAfter(theHeaderElement);
 jQuery(linkDivOpen + sneLink + linkDivClose).insertAfter(theHeaderElement);
}
 }
});