How to remove standard from the article template in newyork?

Rahul Gupta
Tera Contributor

I wanted to remove the standard option from the select article template under knowledge category .

find_real_file.png

Please help me .!!

1 ACCEPTED SOLUTION

JayGervais
Kilo Sage

Hi @Rahul Gupta, I'm not sure if you are still having issues with this but I was also having trouble with this and managed to find a working solution. 

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

View solution in original post

10 REPLIES 10

mahi4889Snow
Tera Contributor

Any idea how to make this happen?