Roles to make breadcrumb widget work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
We seem to be having a role issue with the snh breadcrumb widget. When a user with the itil role views the page in the portal, they see this:
But when a non-itil user looks at the same page:
Note the blank spot in the breadcrumbs. Also if I click on the REQ link, I get a 404 page, likely since the page shows up as undefined in the link: https://lazarddev.service-now.com/sp?id=undefined&sys_id=64af59d02b2c325041a5fc385e91bf78&table=sc_r...
Does anyone have any idea where I can look for what's causing this? I tried giving a read role to the sc_request table without effect
~Conan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Did you create a custom breadcrumb widget? That does not look like the out of the box breadcrumb. Also did you customize your number as there is not normally a dash in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Can you give more information about if any widget was cloned? Or do you create a new taxonomy? Or any user criteria?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Sorry, I apparently wasn't firing on all cylinders. It came from ServiceNow Hackery. Here's the widget details, I put the OOB breadcrumb widget in place and it gives the same behavior.
Server:
(function() {
var thisSession = gs.getSessionID();
if (input) {
if (Array.isArray(input.breadcrumbs)) {
gs.getUser().setPreference('snhbc', JSON.stringify(input.breadcrumbs));
gs.getUser().setPreference('snhses', thisSession);
}
} else {
data.table = $sp.getParameter('table');
data.sys_id = $sp.getParameter('sys_id');
if (data.table) {
var rec = new GlideRecordSecure(data.table);
if (data.sys_id) {
rec.get(data.sys_id);
data.page = rec.getDisplayValue();
if (data.page.indexOf('Created') == 0) {
data.page = null;
}
if (!data.page) {
data.page = rec.getDisplayValue('number');
}
if (!data.page) {
data.page = rec.getDisplayValue('name');
}
if (!data.page) {
data.page = rec.getDisplayValue('short_description');
}
if (!data.page) {
data.page = rec.getLabel();
}
} else {
data.page = rec.getPlural();
}
}
data.breadcrumbs = [];
var snhbc = gs.getPreference('snhbc');
var snhses = gs.getPreference('snhses');
if (snhbc && snhses && snhses == thisSession) {
data.breadcrumbs = JSON.parse(snhbc);
}
}
})();
Client Controller:
function snhBreadcrumbs($scope, $rootScope, $location, spUtil) {
var c = this;
c.expanded = !spUtil.isMobile();
c.expand = function() {
c.expanded = true;
};
c.breadcrumbs = [];
var thisTitle = c.data.page || document.title;
if ($rootScope.portal && $rootScope.portal.title) {
var portalSuffix = ' - ' + $rootScope.portal.title.trim();
var cutoff = thisTitle.indexOf(portalSuffix);
if (cutoff != -1) {
thisTitle = thisTitle.substring(0, cutoff);
}
}
var thisPage = {url: $location.url(), id: $location.search()['id'], label: thisTitle};
if (thisPage.id && thisPage.id != $rootScope.portal.homepage_dv) {
var pageFound = false;
for (var i=0;i<c.data.breadcrumbs.length && !pageFound; i++) {
if (c.data.breadcrumbs[i].id == thisPage.id) {
c.breadcrumbs.push(thisPage);
pageFound = true;
} else {
c.breadcrumbs.push(c.data.breadcrumbs[i]);
}
}
if (!pageFound) {
c.breadcrumbs.push(thisPage);
}
}
c.data.breadcrumbs = c.breadcrumbs;
c.server.update();
c.returnPath = '?';
if (c.breadcrumbs.length > 1) {
c.returnPath = c.breadcrumbs[c.breadcrumbs.length - 2].url;
}
shareReturnPath();
$rootScope.$on('snhShareReturnPath', function() {
shareReturnPath();
});
function shareReturnPath() {
$rootScope.$broadcast('snhBreadcrumbs', {
returnPath: c.returnPath
});
}
}
HTML:
<div aria-label="${Page breadcrumbs}" role="navigation">
<ul class="nav nav-pills nav-sm">
<li>
<span><a ng-href="?id={{portal.homepage_dv}}">${Home}</a>
<i aria-hidden="true" class="fa fa-chevron-right"></i></span>
</li>
<li ng-if="!c.expanded && c.breadcrumbs && c.breadcrumbs.length > 2">
<span><a ng-click="c.expand()"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></a>
<i aria-hidden="true" class="fa fa-chevron-right"></i></span>
</li>
<li ng-if="!c.breadcrumbs"><span><a style="display: inline;" class="a-disabled" aria-current="page" href>{{page.title}}</a></span></li>
<li ng-if="c.expanded || ((c.breadcrumbs.length > 2 && $index > c.breadcrumbs.length-3) || (c.breadcrumbs.length <= 2))" ng-repeat="item in c.breadcrumbs track by $index" >
<span><a ng-if="!$last" ng-href="{{item.url}}">{{item.label}}</a>
<a class="a-disabled" ng-if="$last" aria-current="page" href>{{item.label}}</a>
<i aria-hidden="true" ng-if="!$last" class="fa fa-chevron-right"></i></span>
</li>
</ul>
</div>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Don't worry, it happens. Other question: did you saw if the user preferences was filled with the user that haven't the itil role?
