
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎05-03-2022 01:40 PM
Issue- If you would like to display the "My Incidents(Closed Incident)" or any header Menu with your Header Menu widget regardless of whether or not there is an active incident or record. You would like your users to be able to view their closed incidents. However, My Incidents will not show up in the header menu unless there is at least one active action.
Probable Cause/Challenge:
This is considered standard OOTB behavior for the Header Menu Widget. Within this widget, and the ng-templates that it utilizes, there are conditions that are set the prevent scriptedItems or items from being sent to the widget or rendered to the html unless those scriptedItems or items have a count greater than 0.
Such as with the client script in line 53) of the Header Menu Widget code-
if (item.items || (item.scriptedItems && item.scriptedItems.count != 0 ) ||
and the line within the following blocks for menuTemplate ng-template
<a role="menuitem" aria-haspopup="true" aria-expanded="false" ng-if="item.scriptedItems.count > 0" href data-toggle="dropdown" aria-label="{{::item.label ? item.label + ': ' : ''}}{{::item.hint ? item.hint + ': ' : ''}}{{item.scriptedItems.count}}" title="{{::item.hint}}">
<fa ng-if="::item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="::item.label"></span>
<span ng-if="::!item.scriptedItems.omitBadge" class="label label-as-badge label-primary sp-navbar-badge-count">{{item.scriptedItems.Always}}</span>
<span ng-if="::!item.scriptedItems.omitBadge" class="label label-as-badge label-primary sp-navbar-badge-count">{{item.scriptedItems.count}}</span>
</a>
<sp-dropdown-tree role="menu" aria-label="{{::item.label}}" ng-if="item.scriptedItems.count > 0" items="item.scriptedItems.items" />
Solution-
By modifying these conditions set in menuTemplate and in the Header menu widget's Client Script could be made to allow scriptedItems to show even when scriptedItems.count is = 0, ServiceNow does not support making direct changes being made to OOTB Widgets. And so the recommended solution is that you make a clone of your Header Menu Widget and apply the necessary/below changes there instead.
However, the above change will impact all the header menu items. Hence, to implement these changes we use a set a variable value in the scripted list menu item, and the same can use in the Header menu widget's Client Script and menuTemplate conditions.
Need to complete the following steps to accomplish it.
1. Set a custom variable in the scripted list menu item- Example -t.showAlwaysheader = true;
2. Clone the OOB Widget "Header Menu" widget and add the condition of the code at line number 53 in the client script.
if (item.items || (item.scriptedItems && item.scriptedItems.count != 0)||(item.scriptedItems && item.scriptedItems.showAlwaysheader==true))
3. Similarly create a copy for all the OOB Angular-ng templates and associated that with the cloned Header menu widget as shown below.
4. Ensure that references to each new template are reflected in your cloned widget.
5. Include an Angular Provider for the clone of the spDropDownTree template.
6. Replaced all occurrences of menuTemplate with the custom menuTemplate in the Body HTML for Custom-Header Menu.
7. Add the condition statement with (scripteditems.showAlways) in menuTemplate.
8. Associate the "SP Header Menu" with the cloned custom Header Menu- widget.
- 3,852 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you don't want to modify/clone the OOB widget you can just create a new menu option that links directly to the page and is hidden when the count is >0. Then you have one less thing to have to resolve when performing a system upgrade.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Yeah, I was thinking to achieve the way you said. However, just imagine the case if you have so many header menu items. And it could be the case for all types of action like incidents, Requests, or Approvals.
Having so many header menu items in the portal could change the portal's layout weirdly. Thanks.
Regards,
Nayan
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Well it'd be a 1:1 swap. You'd only ever see one of the two "My Tickets" buttons. At a count of 0 active you'd see the non-dropdown direct link, and at >0 you'd see the one with the dropdown and notification badge.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Without having any active action you won't be able to see the header menu itself and that's the problem with the OOB header. Thanks.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
I have done all the steps in this article but all my links are not working at the top and when i click a scripted list link, it will disappear.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Nayan,
We have this same requirement from customer, I have done all the steps in this article but if I reload service portal link header menu is keep on loading only and not getting the output as expected. Please help us on urgent basis to fix this as soon as possible.
Thanks,
Sivakumar Raman
7676333970
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi All,
I have cloned and updated scripts and also created same Angular provider provided above for custom Header menu widget. But the problem is header menu is showing like keep on loading only, please help us to fix this issue.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Greetings of the day!!
We have cloned and updated scripts and also created same Angular provider provided in the above for custom Header menu widget. But the problem is header menu keeps loading and after some time the loading stops and when we click on header menus then menus (my incidents, my requests, my rfc) are disappearing, please help us to fix this issue. Kindly assist how we can get this sorted out.
Thanks & Regards,
Rajashekar.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Was anyone able to resolve the issue with regards to the menu not loading (that everyone is facing) ? I have the same issue, not sure how to troubleshoot this!