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

This blog was originally published by Fruition Partners. Since then, Fruition Partners has become the ServiceNow practice within DXC Technology.

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);
}
});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: