Content Items not displaying in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 07:41 AM
Hello All,
My team and I are configuring the Service Portal right now and it hasn't been a very pleasant experience. One issue is that the Content Items within the Catalogs do not display in the Service Portal. Does anyone know a work around so the content items can be utilized?
Appreciate any help!
-Marques
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2016 08:20 AM
I ended up modifying the out of the box widgets to accommodate for content items. Two things:
1) Modify the SC Categories widget; clone widget, then update the server script to modify the query to include content items (line 69):
//gr.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard,sc_cat_item_content');
gr.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard');
2) Modify the 'SC Category Page' widget to accommodate for content item fields (URL) and include content items in query. In the Server Script (line 22):
//sc.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard,sc_cat_item_content');
// Need to allow content items in query
sc.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard');
This gets the url field into a variable (added above line 37):
// Get item url if item is content item
if (item.sys_class_name == 'sc_cat_item_content' )
item.url = sc.sc_cat_item.ref_sc_cat_item_content.url.getDisplayValue();
I then modified the HTML template to check for the item type and display the correct variable (item page or URL of content item):
<div class="col-sm-6 col-md-4" ng-repeat="item in data.items">
<div class="panel panel-{{::options.color}} b">
<!-- Modified to account for external links as cat items (sc_cat_item_content) -->
<div ng-if="item.sys_class_name != 'sc_cat_item_content'">
<a href="?id={{item.page}}&sys_id={{item.sys_id}}" class="panel-body block">
<div class="overflow-100">
<h4 class="m-t-none m-b-xs">{{item.name}}</h4>
<img ng-src="{{item.picture}}" ng-if="item.picture" class="m-r-sm m-b-sm item-image pull-left" />
<div class="text-muted item-short-desc">{{item.short_description}}</div>
</div>
</a>
</div>
<div ng-if="item.sys_class_name == 'sc_cat_item_content'">
<a href="{{item.url}}" target="_blank" class="panel-body block">
<div class="overflow-100">
<h4 class="m-t-none m-b-xs">{{item.name}}</h4>
<img ng-src="{{item.picture}}" ng-if="item.picture" class="m-r-sm m-b-sm item-image pull-left" />
<div class="text-muted item-short-desc">{{item.short_description}}</div>
</div>
</a>
</div>
<div class="panel-footer">
<a ng-if="item.sys_class_name != 'sc_cat_item_content'" href="?id={{item.page}}&sys_id={{item.sys_id}}" class="pull-left text-muted">${View Details}</a>
<a ng-if="item.sys_class_name == 'sc_cat_item_content'" href="{{item.url}}" target="_blank" class="pull-left text-muted">${View Details}</a>
<span ng-if="item.price != '$0.00'" class="pull-right item-price font-bold">{{item.price}}</span>
</div>
Now, the category count on the left includes the content items, and when the content item panel is displayed, the url of the content item is in the <a> tag instead of the cat item page.
Hope that makes sense.
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 02:09 PM
The other thing to take into account with content items is they do not appear in the search by default. I modified the 'Search Page' widget with the following:
Server Script (line 84- not sure what getSCRecord does exactly, no documentation from what I can see. It must limit the types of items which return in the query):
//var sc = $sp.getSCRecord();
// Modified to include more than just sc_cat_item - timmo
var sc = new GlideRecord('sc_cat_item');
Line 96 (include sys_class_name in list of item vars):
$sp.getRecordDisplayValues(item, sc, 'name,short_description,picture,price,sys_id,sys_class_name');
Set the 'item.page' variable based on item type (line 98):
// Modified to include URL from Content Items |
if (item.sys_class_name == 'Content Item') {
item.page = sc.ref_sc_cat_item_content.url.getDisplayValue(); |
} else {
item.page = sc.getRecordClassName() == 'sc_cat_item_guide' ? 'sc_cat_item_guide' : 'sc_cat_item';
}
Modify the HTML template to check which item type and set the <a> tag correctly (line 34):
<a ng-if="item.sys_class_name != 'Content Item'" href="?id={{item.page}}&sys_id={{item.sys_id}}" class="h4 text-primary m-b-sm block"><i class="fa fa-shopping-cart m-r-sm"></i><span ng-bind-html="highlight(item.name, data.q)"></span></a>
<a ng-if="item.sys_class_name == 'Content Item'" href="{{item.page}}" target="_blank" class="h4 text-primary m-b-sm block"><i class="fa fa-shopping-cart m-r-sm"></i><span ng-bind-html="highlight(item.name, data.q)"></span></a>
Now, when the Content item is returned in the search results, clicking the link opens the external URL.
Keep in mind, both of my modifications were to accommodate for "External" content item type (a URL). If you have other content item types, you'll have to modify the code to pass the appropriate variables to the view.
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2016 03:19 PM
Hey all (especially b-rad)
There's mention above of a fix in patch 3, but we're seeing these symptoms on Patch 5 - has anyone confirmed that this is resolved in an instance that they own? We need Content Items in our instance.
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2016 06:14 AM
Are the content items not showing up in a certain page or widget? We're on patch 5, but I have modified the OOB widget, so I can't test with that. When I look at the updated OOB widget, it appears to be not be excluding content items as it did prior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2016 06:12 PM
Hi Tim,
Thanks for the reply - We've tested in a virgin instance and all is working fine and we're not "OOB" on the widgets that are affected, so we're working through reintegrating the SN code back into our affected widgets.
Cheers,
Kevin