- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2019 08:32 AM
Hopefully this is quick and easy!
I am trying to update the breadcrumbs on my portal to get the portal's catalog and not just the first catalog attached to a catalog item (some items are in multiple catalogs).
How do I access this data in a script? I tried $sp.getParameter('catalog') and it didn't work. I am having trouble finding documentation on possible parameters and other get methods for the portal.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 08:33 AM
Here is what I got to work!!! Thank you so much for pointing me in the right direction
Server script-
//current catalog item
data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);
//get the default catalog from the portal via query
var portalGr = $sp.getPortalRecord().getUniqueValue();//sysId of current portal
var portalcataloggr = new GlideRecord("m2m_sp_portal_catalog");//table which stores portal catalog relation
portalcataloggr.addEncodedQuery('sp_portal.sys_idSTARTSWITH'+ portalGr +'^active=true');
portalcataloggr.query();
//set the name and url for the catalog
if (portalcataloggr.next()) {
data.catalog = {
name : portalcataloggr.getDisplayValue('sc_catalog'),
//SPECIFIY CATALOG HOMEPAGE HERE
url: 'it_sc_category'}
}
//get the current category for the item based on the current catalog
//var catalog = portalcataloggr.sc_catalog;
var categorygr = new GlideRecord('sc_cat_item_category');
categorygr.addEncodedQuery('sc_cat_item='+ data.sc_cat_item.sys_id + '^sc_category.sc_catalog=' + portalcataloggr.sc_catalog );
categorygr.query();
if(categorygr.next()){
data.category = {
name: categorygr.getDisplayValue('sc_category'),
url: '?id=sc_category&sys_id=' + categorygr.sc_category
}
}
client controller-
// Breadcrumbs
if ($scope.data.sc_cat_item) {
var bc = [{label: $scope.data.catalog.name, url: '?id=' + $scope.data.catalog.url}];
if ($scope.data.category)
bc[bc.length] = {label: $scope.data.category.name, url: $scope.data.category.url};
bc[bc.length] = {label: $scope.data.sc_cat_item.name, url: '#'};
$rootScope.$broadcast('sp.update.breadcrumbs', bc);
spUtil.setSearchPage('sc');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2019 07:01 AM
This looks great. I was hoping there was some magical shortcut method like $sp.getCatalog that I just wasn't aware of lol. I suppose a query will do.
I'll let you know how it works!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2019 08:33 AM
Here is what I got to work!!! Thank you so much for pointing me in the right direction
Server script-
//current catalog item
data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);
//get the default catalog from the portal via query
var portalGr = $sp.getPortalRecord().getUniqueValue();//sysId of current portal
var portalcataloggr = new GlideRecord("m2m_sp_portal_catalog");//table which stores portal catalog relation
portalcataloggr.addEncodedQuery('sp_portal.sys_idSTARTSWITH'+ portalGr +'^active=true');
portalcataloggr.query();
//set the name and url for the catalog
if (portalcataloggr.next()) {
data.catalog = {
name : portalcataloggr.getDisplayValue('sc_catalog'),
//SPECIFIY CATALOG HOMEPAGE HERE
url: 'it_sc_category'}
}
//get the current category for the item based on the current catalog
//var catalog = portalcataloggr.sc_catalog;
var categorygr = new GlideRecord('sc_cat_item_category');
categorygr.addEncodedQuery('sc_cat_item='+ data.sc_cat_item.sys_id + '^sc_category.sc_catalog=' + portalcataloggr.sc_catalog );
categorygr.query();
if(categorygr.next()){
data.category = {
name: categorygr.getDisplayValue('sc_category'),
url: '?id=sc_category&sys_id=' + categorygr.sc_category
}
}
client controller-
// Breadcrumbs
if ($scope.data.sc_cat_item) {
var bc = [{label: $scope.data.catalog.name, url: '?id=' + $scope.data.catalog.url}];
if ($scope.data.category)
bc[bc.length] = {label: $scope.data.category.name, url: $scope.data.category.url};
bc[bc.length] = {label: $scope.data.sc_cat_item.name, url: '#'};
$rootScope.$broadcast('sp.update.breadcrumbs', bc);
spUtil.setSearchPage('sc');
}