Name
sn_cd.cd_ContentLocationAJAX
Description
API to get content locations
Script
var cd_ContentLocationAJAX = Class.create();
cd_ContentLocationAJAX.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getContentLocations: function() {
var result = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('name', 'sn_cd_content_visibility');
gr.addQuery('element', 'content_location');
gr.addQuery('language', gs.getSession().getLanguage());
gr.orderBy('sequence');
gr.query();
while(gr.next()) {
result.push({
label: gr.getDisplayValue('label'),
value: gr.getValue('value')
});
}
var parser = new global.JSON();
return parser.encode({
locations: result
});
},
getScheduledWidgetForContent: function() {
if (!(new GlidePluginManager().isActive('com.sn_content_governance')))
return null;
var contentSysId = this.getParameter('sysparm_content_sys_id');
var contentRequestItem = this.getParameter('sysparm_content_request_item');
if (!contentSysId) { // Get content sys_id with a query to Content Request Item
var criGr = new GlideRecord(sn_cg.cg_CommonConstants.CONTENT_REQUEST_ITEM);
criGr.get(contentRequestItem);
contentSysId = criGr.getValue('content');
}
var scheduleGr = new GlideRecord(cd_CommonConstants.CONTENT_TABLE_CONTENT_VISIBILITY);
scheduleGr.addQuery("content", contentSysId);
scheduleGr.addQuery("content_request_item", contentRequestItem);
scheduleGr.setLimit(1);
scheduleGr.query();
if (scheduleGr.next()) {
var spInstance = scheduleGr.getValue("sp_instance");
var spPage = scheduleGr.getDisplayValue("sp_page");
var topicId = "";
var parser = new global.JSON();
var pageId = scheduleGr.getValue("sp_page");
if (pageId) {
var pageGr = new GlideRecord("sp_page");
if (pageGr.get(pageId))
if (pageGr.category != "sn_ex_sp_taxonomy");
topicId = scheduleGr.getValue("topic");
}
return parser.encode({
sp_instance: spInstance,
sp_page: spPage,
topic_id: topicId,
content: contentSysId
});
}
return null;
},
type: 'cd_ContentLocationAJAX'
});
Sys ID
8323a1d4772001106220a5424f5a9975