logo

NJP

Display Service Portal header menu items with zero count( Even if a user doesn't have active approvals or requests or actions)

Import · May 03, 2022 · article

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





{{item.scriptedItems.Always}}

{{item.scriptedItems.count}}



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)||(i*tem.scriptedItems && item.scriptedItems.showAlwaysheader==true*))

image

3. Similarly create a copy for all the OOB Angular-ng templates and associated that with the cloned Header menu widget as shown below.

image

4. Ensure that references to each new template are reflected in your cloned widget.

image

5. Include an Angular Provider for the clone of the spDropDownTree template.

image

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.

image

8. Associate the "SP Header Menu" with the cloned custom Header Menu- widget.

image

image

View original source

https://www.servicenow.com/community/itsm-articles/display-service-portal-header-menu-items-with-zero-count-even-if/ta-p/2304546