
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 08:56 AM
Hi community,
Is there a way to keep the header menus (My requests, my approvals', etc) in the header menu of the service portal always visible even if the user doesn't have anything there?
Currently, the menus only show when the user has at least one item in those menus but we need it to show all the time.
I have modified the menuTemplate to see if it would keep it visible but it didn't do anything. I also cloned the header menu widget and it didn't show anything at all in the header... Please see below.
Updated menuTemplate
<a ng-if="item.items.length == 0 && !item.scriptedItems" ng-href="{{item.href}}">{{ item.label }}</a>
<a ng-if="item.items.length > 0" href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ item.label }} <span class="caret"></span></a>
<ul ng-if="item.items.length > 0" class="dropdown-menu" role="menu">
<li ng-repeat="item in item.items" ng-include="'menuTemplate'" />
</ul>
<a ng-if="item.scriptedItems.count" href="javascript:void(0)" data-toggle="dropdown" title="{{item.hint}}">
<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.count}}</span>
</a>
<sp-dropdown-tree ng-if="item.scriptedItems.count" items="item.scriptedItems.items" />
Updated Menu Header Widget - client script (line 47)
function ($scope, spUtil, $rootScope, $timeout, spAriaUtil) {
$scope.loadingIndicator = $rootScope.loadingIndicator;
$scope.cartItemCount = 0;
$scope.wishlistItemCount = 0;
$scope.itemAddedTooltipOpen = false;
$scope.accessibilityEnabled = spAriaUtil.g_accessibility === "true";
$scope.$on("$sp.service_catalog.cart.count", function($evt, count) {
$scope.cartItemCount = count;
});
$scope.$on("$sp.service_catalog.wishlist.count", function($evt, count) {
$scope.wishlistItemCount = count;
});
var cancelTooltipPromise;
$scope.$on("$sp.service_catalog.cart.add_item", function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = true;
cancelTooltipPromise = $timeout(function() {
$scope.itemAddedTooltipOpen = false;
}, 3000);
});
$scope.$on('sp_loading_indicator', function(e, value) {
$scope.loadingIndicator = value;
});
$scope.toggleCart = function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = false;
$timeout(function() {
$("#cart-dropdown").dropdown("toggle");
});
};
// PRB1108244: visibleItems array is used to improve keyboard nav
// in menu, refresh it as needed
$scope.$watch('data.menu.items', function() {
$scope.visibleItems = [];
if ($scope.data.menu.items) {
for (var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.items || (item.scriptedItems && item.scriptedItems.count >= 0))
$scope.visibleItems.push(item);
}
}
}, true);
// Get list of record watchers
var record_watchers = [];
if ($scope.data.menu.items) {
for(var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.type == 'scripted') {
if (item.scriptedItems.record_watchers)
record_watchers = record_watchers.concat(item.scriptedItems.record_watchers);
}
if (item.type == 'filtered') {
record_watchers.push({'table':item.table,'filter':item.filter});
}
}
}
// Init record watchers
for (var y in record_watchers){
var watcher = record_watchers[y];
spUtil.recordWatch($scope, watcher.table, watcher.filter);
}
}
Can anyone tell me what I am doing wrong? How can I get the header menus show up all the time?
Any help is appreciated!
Thank you,
Yeny
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 09:21 AM
I'm on Kingston and this works for me...
menuTemplate:
<a ng-if="item.items.length == 0 && !item.scriptedItems" ng-href="{{::item.href}}" target="{{::item.url_target}}" title="{{::item.hint}}">
<fa ng-if="::item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="::item.label"></span>
</a>
<a role="button" ng-if="item.items.length > 0" href class="dropdown-toggle sp-menu-has-items" data-toggle="dropdown" aria-controls="menu-apply" aria-haspopup="true" title="{{::item.hint}}">
<fa ng-if="::item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="::item.label"></span> <span class="caret"></span>
</a>
<ul ng-if="item.items.length > 0" class="dropdown-menu" role="group" id="menu-apply">
<li ng-repeat="item in item.items" ng-include="'menuTemplate'" />
</ul>
<a role="button" ng-if="item.scriptedItems.count >= 0" href data-toggle="dropdown" 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.count}}</span>
</a>
<sp-dropdown-tree role="menu" aria-label="{{::item.label}}" ng-if="item.scriptedItems.count >= 0" items="item.scriptedItems.items" />
Client Controller:
function ($scope, spUtil, $rootScope, $timeout, spAriaUtil) {
$scope.loadingIndicator = $rootScope.loadingIndicator;
$scope.cartItemCount = 0;
$scope.wishlistItemCount = 0;
$scope.itemAddedTooltipOpen = false;
$scope.accessibilityEnabled = spAriaUtil.g_accessibility === "true";
$scope.$on("$sp.service_catalog.cart.count", function($evt, count) {
$scope.cartItemCount = count;
});
$scope.$on("$sp.service_catalog.wishlist.count", function($evt, count) {
$scope.wishlistItemCount = count;
});
var cancelTooltipPromise;
$scope.$on("$sp.service_catalog.cart.add_item", function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = true;
cancelTooltipPromise = $timeout(function() {
$scope.itemAddedTooltipOpen = false;
}, 3000);
});
$scope.$on('sp_loading_indicator', function(e, value) {
$scope.loadingIndicator = value;
});
$scope.toggleCart = function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = false;
$timeout(function() {
$("#cart-dropdown").dropdown("toggle");
});
};
// PRB1108244: visibleItems array is used to improve keyboard nav
// in menu, refresh it as needed
$scope.$watch('data.menu.items', function() {
$scope.visibleItems = [];
if ($scope.data.menu.items) {
for (var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.items || (item.scriptedItems && item.scriptedItems.count >= 0))
$scope.visibleItems.push(item);
}
}
}, true);
// Get list of record watchers
var record_watchers = [];
if ($scope.data.menu.items) {
for(var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.type == 'scripted') {
if (item.scriptedItems.record_watchers)
record_watchers = record_watchers.concat(item.scriptedItems.record_watchers);
}
if (item.type == 'filtered') {
record_watchers.push({'table':item.table,'filter':item.filter});
}
}
}
// Init record watchers
for (var y in record_watchers){
var watcher = record_watchers[y];
spUtil.recordWatch($scope, watcher.table, watcher.filter);
}
}
Then just make sure you associate this correctly to your menutemplate and other angular ng-templates (should be at least 3)
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2019 05:43 AM
Do we have any way to do it now?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 09:21 AM
I'm on Kingston and this works for me...
menuTemplate:
<a ng-if="item.items.length == 0 && !item.scriptedItems" ng-href="{{::item.href}}" target="{{::item.url_target}}" title="{{::item.hint}}">
<fa ng-if="::item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="::item.label"></span>
</a>
<a role="button" ng-if="item.items.length > 0" href class="dropdown-toggle sp-menu-has-items" data-toggle="dropdown" aria-controls="menu-apply" aria-haspopup="true" title="{{::item.hint}}">
<fa ng-if="::item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="::item.label"></span> <span class="caret"></span>
</a>
<ul ng-if="item.items.length > 0" class="dropdown-menu" role="group" id="menu-apply">
<li ng-repeat="item in item.items" ng-include="'menuTemplate'" />
</ul>
<a role="button" ng-if="item.scriptedItems.count >= 0" href data-toggle="dropdown" 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.count}}</span>
</a>
<sp-dropdown-tree role="menu" aria-label="{{::item.label}}" ng-if="item.scriptedItems.count >= 0" items="item.scriptedItems.items" />
Client Controller:
function ($scope, spUtil, $rootScope, $timeout, spAriaUtil) {
$scope.loadingIndicator = $rootScope.loadingIndicator;
$scope.cartItemCount = 0;
$scope.wishlistItemCount = 0;
$scope.itemAddedTooltipOpen = false;
$scope.accessibilityEnabled = spAriaUtil.g_accessibility === "true";
$scope.$on("$sp.service_catalog.cart.count", function($evt, count) {
$scope.cartItemCount = count;
});
$scope.$on("$sp.service_catalog.wishlist.count", function($evt, count) {
$scope.wishlistItemCount = count;
});
var cancelTooltipPromise;
$scope.$on("$sp.service_catalog.cart.add_item", function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = true;
cancelTooltipPromise = $timeout(function() {
$scope.itemAddedTooltipOpen = false;
}, 3000);
});
$scope.$on('sp_loading_indicator', function(e, value) {
$scope.loadingIndicator = value;
});
$scope.toggleCart = function() {
$timeout.cancel(cancelTooltipPromise);
$scope.itemAddedTooltipOpen = false;
$timeout(function() {
$("#cart-dropdown").dropdown("toggle");
});
};
// PRB1108244: visibleItems array is used to improve keyboard nav
// in menu, refresh it as needed
$scope.$watch('data.menu.items', function() {
$scope.visibleItems = [];
if ($scope.data.menu.items) {
for (var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.items || (item.scriptedItems && item.scriptedItems.count >= 0))
$scope.visibleItems.push(item);
}
}
}, true);
// Get list of record watchers
var record_watchers = [];
if ($scope.data.menu.items) {
for(var i in $scope.data.menu.items) {
var item = $scope.data.menu.items[i];
if (item.type == 'scripted') {
if (item.scriptedItems.record_watchers)
record_watchers = record_watchers.concat(item.scriptedItems.record_watchers);
}
if (item.type == 'filtered') {
record_watchers.push({'table':item.table,'filter':item.filter});
}
}
}
// Init record watchers
for (var y in record_watchers){
var watcher = record_watchers[y];
spUtil.recordWatch($scope, watcher.table, watcher.filter);
}
}
Then just make sure you associate this correctly to your menutemplate and other angular ng-templates (should be at least 3)
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2018 08:05 AM
Hi Allen,
Thank you so much for your response! I tried your script and it does show the header menu as expected but there's another issue that is happening now. The portal takes a long time to fully load and I'm pretty sure it's due to the cloned Header Menu widget because that's the only change that I made to the change aside from the Menu template.
So I added the code menuTemplate code you provided and the menus appear even if it's 0 which is great! But this happens afterwards...
Loading (with correct color theme i want)
After a few minutes
after I click on Wait and finishes loading after a couple more minutes (not the color theme I want and the links don't work - doesn't drop down)
I've used the same client script in the cloned Header Menu widget you provided so I am not sure what's causing the issue... Have you encountered this before? Any ideas what could be causing it?
Thank you,
Yeny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2018 12:59 PM
Nevermind! I figured out my issue... and it was right in my face the whole time... and you were right, there are 3 templates that need to be associated and I was missing two lol thank you so much!!!I really appreciate your help!
Yeny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2018 01:05 PM
Haha yea, I only mentioned that because I didn't do that and was freaking out and figured out that I needed to associate those three templates.
Also, side note, you'll need to also now associate that same new header for the other menus as well (like SP Config, HR, etc. if applicable). You won't need to associate the three templates, but the header bar will lock up (like it did just a moment ago for you) in those other portal areas that use a header.
So go to Service Portal > Menus and then see which ones don't have the same widget assigned. For me, I only needed to just change SP Config. There's another Benchmarks ones, but I don't know what that is and didn't change it, yet.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!