Name
sn_ex_sp.TopicPageUtilSNC
Description
WARNING Customers should NOT modify this script The purpose of this script include is to provide default behaviours for the TopicPageUtil script include. To change the behaviour of these methods (or add new methods), Customers should override/add new methods to the TopicPageUtil script include.
Script
var TopicPageUtilSNC = Class.create();
TopicPageUtilSNC.prototype = {
initialize: function() {
this.SYS_PROPERTY_ICON = 'sn_ex_sp.default.taxonomy.icon';
},
/**
* Returns the breadcrumbs from topic to its parent
* @param topicId - sys_id of topic
* returns the final array having breadcrumb information to display in widget
**/
fetchBreadCrumbsForTopic: function(topicId) {
var breadcrumb = [];
breadCrumb = this._fetchBreadCrumbsForTopic(topicId, breadcrumb);
return breadCrumb;
},
/**
* Returns default topic icon image name
**/
fetchDefaultIconImage: function() {
return this._fetchImage(this.SYS_PROPERTY_ICON);
},
_fetchBreadCrumbsForTopic: function(topicId, breadcrumb) {
var parentTopic;
var gr = new GlideRecord("topic");
gr.addQuery("active", true);
gr.addQuery("sys_id", topicId);
gr.query();
while (gr.next()) {
var topicName = gr.getDisplayValue('name');
var pageToRedirect = gr.getDisplayValue('template') || 'emp_taxonomy_topic';
breadcrumb.unshift({
"label": topicName,
"url": '?id='+ pageToRedirect +'&topic_id=' + topicId + '&in_context=true'
});
parentTopic = gr.getValue("parent_topic");
}
if (parentTopic != null)
this._fetchBreadCrumbsForTopic(parentTopic, breadcrumb);
return breadcrumb;
},
_fetchImage: function(sys_property) {
var image_record = gs.getProperty(sys_property, '');
var gr = new GlideRecord('db_image');
gr.addQuery('sys_id', image_record);
gr.addActiveQuery();
gr.query();
if(gr.next())
return gr.getDisplayValue('image');
return '';
},
getIcon: function(topicId) {
var gr = new GlideRecord("topic");
gr.get(topicId);
if(gr.icon_url)
return gr.icon_url.toString();
if(gr.icon)
return gr.getDisplayValue('icon') + '?t=small';
return null;
},
getBannerImage: function(topicId) {
var gr = new GlideRecord('topic');
gr.get(topicId);
if(gr.banner_image_url)
return gr.banner_image_url.toString();
if(gr.banner_image)
return gr.banner_image.getDisplayValue();
return null;
},
type: 'TopicPageUtilSNC'
};
Sys ID
6aa992a8c35430105a09f0ad9840dd45