Name
global.SkillTaxonomyUtil
Description
This script include contains helper methods related to Skill Taxonomy.
Script
var SkillTaxonomyUtil = Class.create();
SkillTaxonomyUtil.prototype = {
initialize: function() {
},
getAssociatedSkills: function(category) {
var skills = [];
var gr = new GlideRecord('cmn_skill_m2m_category');
gr.addQuery('category', category);
gr.query();
while(gr.next()) {
skills.push(gr.getValue('skill'));
}
return skills;
},
hasCycle: function(parent) {
while(!gs.nil(parent + '')) {
if(current.getUniqueValue() == parent.sys_id + '') {
return true;
}
parent = parent.parent;
}
return false;
},
hasChildCategories: function(category) {
var gr = new GlideRecord('cmn_skill_category');
gr.addQuery('parent', category);
gr.query();
return gr.getRowCount() > 0;
},
hasSkills: function(category) {
var gr = new GlideRecord('cmn_skill_m2m_category');
gr.addQuery('category', category);
gr.query();
return gr.getRowCount() > 0;
},
updateChildrenPath: function(current) {
var gr = new GlideRecord('cmn_skill_category');
gr.addQuery('parent', current);
gr.query();
while(gr.next()) {
gr.category_path = this.getPath(gr);
gr.update();
}
},
getPath: function(gr) {
if (gs.nil(gr)) {
return '';
}
var parentPath = gs.nil(gr.parent) ? '' : gr.parent.category_path;
var currentPath = gr.code + '/';
return parentPath + currentPath;
},
disconnectChildren: function(parent) {
var gr = new GlideRecord('cmn_skill_category');
gr.addQuery('parent', parent);
gr.query();
while(gr.next()) {
gr.setValue('parent', '');
gr.update();
}
},
type: 'SkillTaxonomyUtil'
};
Sys ID
d2df17b8b3232300290ea943c6a8dc00