Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Jim Coyne
Kilo Patron
Part of the "Tips 'N Tricks" series.

 

NOTE: This may not be as helpful now with the new "Next Experience" Unified Navigation (Polaris) that supports opening new tabs/windows with the full UI, but still relevant.

 

Sometimes you might end up with a tab/window that only contains the main window, either with a form, list or some UI Page, without the banner and Navigator surrounding the frame.  You probably cmd+clicked a link to open a form or list in the new tab/window.

 

Sometimes we want to get back into the full frame UI, including the banner and Navigator.   It's easy to do, just have to add "nav_to.do?uri=" between "service-now.com/" and the rest of the URL.   But that can be a pain, so I created a bookmarklet to help.

 

All you have to do is create a new bookmark in your favourite browser, name it "nav_to" or whatever you want and paste the following code into the URL or Location field:

 

javascript: (function(){
  /* now supports multiple domains */
  try {
    const domain = [".service-now.com/", ".custom-domain.com/"];
    var found = false;
    var url = window.location.toString();


    /* loop through each domain */
    domains = domain.length;
    let i = 0;
    do {
      /* is it a domain we are interested in AND "nav_to.do" is NOT already in the URL */
      if (url.indexOf(domain[i]) > -1 && url.indexOf(domain[i] + "nav_to.do") == -1) {
        found = true;
        url = url.replace(domain[i], domain[i] + "nav_to.do?uri=");
        window.location = url;
      }
      i++;
    } while (i < domains && !found);


  } catch(err) {}
})();

 

NOTE: When you paste the code into the bookmark/favourite, change "&colon;" in the first line of code above with the actual colon character ":".

 

You will end up with a bookmark you can click to quickly switch you into the full UI:

 

find_real_file.png

 

The code now supports looking for URLs in multiple domains (my current client is using the Custom URL feature, so I may be logged into the instance via the service-now.com or the custom domain).  It will loop through the list of domains and if it finds it AND if the URL does NOT contain "nav_to.do", it will replace "domain name/" with "domain name/nav_to.do?uri=" and then reloads the page.  Most users can just use:

 

const domain = [".service-now.com/"];

 

...if you are not using Custom URLs.

 

Simple and effective.  There is not a lot of checking for certain strings in the URL to ensure it is a valid ServiceNow URL, but that would be way too complicated: have to let the user make some decisions on their own before clicking away.  🤓

4 Comments