Add a new menu item in ServiceNow’s header profile dropdown

One of the strengths of ServiceNow is its flexibility and the customization capability it offers. In this Tips & Tricks article you will learn one of the many ways ServiceNow can be adapted to your user needs.

Imagine the following situation:
You would like to add a new menu item in the profile dropdown which is in the header (for example to add a toggle switch between the normal interface and the service portal/CMS).

Add a new menu item ServiceNow

The idea behind this is to tailor the navigation options to make it faster for your users to access what they need. This can be achieved by implementing a global UI script with the following code in it:

addLoadEvent(function(){
      Try{
             var addItem = (window.top.$j(“#custom_menu_item_1”).length == 0);
              if (g_user.hasRoles() && addItem) {
                  //Replace ‘onclick’ by ‘href’ with the suffix of the portal
                  var menuItem = “<li><a id=’custom_menu_item_1′ onclick=’alert(\”Will switch to
                  portal\”)’>” + getMessage(“Switch to Portal”) + “</a></li>”;
                  var menuList = window.top.$j(“ul.dropdown-menu”);
                  if(menuList.length > 0){
                      menuList.append(menuItem);
                  }
              }
      }catch(e){
           //Uncomment for debugging
         //alert(e);
     }
});

mm
Loic joined the company in 2010 and works as Principal Consultant in our Nyon office. He is certified ServiceNow System Administrator, Implementation Specialist and ServiceNow Instructor. With a strong technical background, he is focusing on Solution Consulting since 2011 and is specialised in the areas of CMDB, Asset and ITOM.
Recent Posts

Leave a Comment

Start typing and press Enter to search