- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2019 05:17 AM
I wanted to remove the standard option from the select article template under knowledge category .
Please help me .!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2020 10:26 AM
Hi
Within the ArticleTemplateUtil script include, you can add a method that overrides the getArticleTemplatesForKnowledgeBase method in the ArticleTemplateUtilSNC script.
Within the ArticleTemplateUtil script, the code is as follows:
var ArticleTemplateUtil = Class.create();
ArticleTemplateUtil.prototype = Object.extendsObject(ArticleTemplateUtilSNC,{
// script override to disable Standard KB template
getArticleTemplatesForKnowledgeBase: function(kbId, addNames) {
var gr = new GlideRecord('kb_template_m2m_knowledge_base');
gr.addQuery('kb_knowledge_base',kbId);
gr.query();
var templates = {};
if(!addNames)
templates['kb_knowledge'] = true;
if(!gr.hasNext()){
var template = new GlideRecord('kb_article_template');
template.addActiveQuery();
template.query();
while(template.next()){
if(addNames)
templates[template.child_table] = template.getDisplayValue('article_template');
else
templates[template.child_table] = true;
}
return templates;
}
else {
while(gr.next()){
if(gr.kb_article_template.active){
if(addNames)
templates[gr.kb_article_template.child_table] = gr.kb_article_template.getDisplayValue();
else
templates[gr.kb_article_template.child_table] = true;
}
}
}
return templates;
},
// --
type: 'ArticleTemplateUtil'
});
Hopefully this helps.
Regards,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 08:43 AM
Hi
I tried the code you suggested but i keep getting this error. I am not sure what i am doing wrong. Please help. Thanks.
var ArticleTemplateUtil = Class.create();
ArticleTemplateUtil2.prototype = Object.extendsObject(ArticleTemplateUtil2SNC,{
// script override to disable Standard KB template
getArticleTemplatesForKnowledgeBase: function(kbId, addNames) {
var gr = new GlideRecord('kb_template_m2m_knowledge_base');
gr.addQuery('kb_knowledge_base',kbId);
gr.query();
var templates = {};
if(!addNames)
templates['kb_knowledge'] = true;
if(!gr.hasNext()){
var template = new GlideRecord('kb_article_template');
template.addActiveQuery();
template.query();
while(template.next()){
if(addNames)
templates[template.child_table] = template.getDisplayValue('article_template');
else
templates[template.child_table] = true;
}
return templates;
}
else {
while(gr.next()){
if(gr.kb_article_template.active){
if(addNames)
templates[gr.kb_article_template.child_table] = gr.kb_article_template.getDisplayValue();
else
templates[gr.kb_article_template.child_table] = true;
}
}
}
return templates;
},
// --
type: 'ArticleTemplateUtil'
});
// My original code starts here
getFieldsForTemplate: function(){
var template = this.getParameter("sysparm_template");
var fields = this.getFieldsDataForTemplate(template);
var result = {
fields: fields,
template: template
};
return JSON.stringify(result);
},
getFieldsDataForTemplate: function(template){
var fields = [];
if(template == 'kb_knowledge'){
fields.push( {
field: '',
type: 'HTML'
});
return fields;
}
var gr = new GlideRecord('kb_article_template_definition');
gr.addQuery('article_template.child_table',template);
gr.addActiveQuery();
gr.orderBy('order');
gr.query();
while(gr.next()){
var collapsible, collapsed, collapse_type = gr.getValue('collapsible');
if(collapse_type == 'expanded'){
collapsible = true;
collapsed = false;
} else if(collapse_type == 'collapsed') {
collapsible = true;
collapsed = true;
} else {
collapsible = false;
collapsed = false;
}
fields.push( {
field: gr.getDisplayValue('column_label'),
type: gr.getDisplayValue('column_type'),
column: gr.getValue('table_column'),
collapsible: collapsible,
collapsed: collapsed,
heading_style: gr.getDisplayValue('heading_style'),
field_style: gr.getDisplayValue('field_style'),
preview_text: gr.getValue('u_preview_text'), //Added to see the Preview Text on the kb_knowledge_create_template_preview ui macro
});
}
return fields;
},
type: 'ArticleTemplateUtil'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 10:41 AM
Hey there,
What error are you getting and where did you add the code script?
Cheers,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2021 05:41 AM
Thanks
This helped !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2021 06:40 AM
Hi,
We had the same requirement, we could remove it from the ui for a particular knowledge base however how to achieve the same for the workspace view.
Thanks,
UD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2024 01:26 PM
Hello Urmilla,
I have the same requirement to remove Standard from particular knowledge base but above script does for all all. How did you manage? please advise.
Thanks,
Gita