Skip to content
thesnowmonk.com

thesnowmonk.com

Servicenow Tips, Tricks and More.

Menu
  • Home
  • About
  • Contact Us
Menu

Boost Your ServiceNow Interface: How to Build a Scalable Menu Widget for Seamless Navigation

Posted on August 15, 2022July 8, 2023 by Arun

Okay okay, it’s time for another awesome blog post filled with loaded information that you can take away for your ServiceNow projects.

The Use Case

Ever come across a scenario where you needed to build a page that has a couple of menu links in it? Well, guess what?! Today is your lucky day. We will be building a menu solution that is not only scalable but also less code intensive. The screengrab below illustrates what you will be building.

The widget that renders the menu

The html responsible for displaying the menu is rather straight forward. You have a main container that houses all the sections. These sections are then repeated based on the number of menu items present. Within the section are clickable links, this again is governed by the number of sub menu items present.

<h5>{{ data.widgetTitle }}</h5>
<div class="menu-container">
  <div class="section" ng-repeat="section in data.menu.items">
    <h4>{{ section.label }}</h4>
    <div class="item" ng-repeat= "item in section.items">
      <h5 class="m-t-sm m-b-sm">
        <a class="clickContent small-secondary-button" 
           ng-href={{item.href}} 
           target="{{item.target}}"
           data-id={{item.sys_id}} 
           data-src="sc_cat_item" 
           data-type="detail">
          {{item.label}}
        </a>
      </h5>
    </div>
  </div>  
</div>

My CSS styles are super basic,

.menu-container {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -1rem;

  .section {
    flex: 0 0 30%;
    border: 1px solid rgba(0,0,0,.15);
    margin: 1rem;
    padding: 1rem;
    
    a {
      width: 100%;
    }
  }

}

The same goes with the server script, nothing too fancy here. All we’re doing here is fetching the widget instance from the option you select in the options screen.

(function () {
	data.widgetTitle = gs.getMessage('get_help_prompt');
	data.menuWidget = $sp.getWidgetFromInstance( options.menu );
	data.menu = data.menuWidget.data.menu;
})();

Setting up the data to be rendered

This is the crucial bit, since we’re fetching the data from the menu instances, let go right ahead and create an entry. Head over to Service Portal > Menus.

I’ve created an entry called – ‘Open a Ticket’, within this I have configured 2 menu items

Let me open up a menu item and show you how the configuration looks like, and also the sub menus,

Now, for the last but important bit. You need to create a page and place this widget so that it get’s rendered. For that, head over to Service Portal > Pages. I created a page called – ‘Sample Page‘ and place the widget – Open a ticket.

In the widget instance, make sure to add the additional options

{
	"menu": {
		"value": "27ac7913973f2110c752b0efe153af81",
		"displayValue": "Open a Ticket"
	}
}

And that’s it! Give this one a go and have your own personalized scalable menu.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About This Site

This site is developed and maintained by a ServiceNow developer just like you! An ardent snowhead who is giving you tried and tested tips, tricks and other snippets to get you ahead of the game.

©2025 thesnowmonk.com | Built using WordPress and Responsive Blogily theme by Superb