unable to remove article templates for particular knowledge base

Gopal14
Tera Contributor

Hi Team,

 

 

I want to remove knowledge base article template for few knowledge bases, I have tried but not working.

 

Gopal14_0-1755166161825.png

 

when I click on Customer Service knowledge base, I have standard and Known Error article Templates. I want to remove Known Error article template, So when I click on Customer Service knowledge base, It needs to show only Standard article template only.

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Gopal14 

This article provides you with how to add the article to a knowledge base, and in the same way, you can unlink it as well."

 

https://www.servicenow.com/community/knowledge-managers/assign-article-template-to-a-specific-knowle....

 

DrAtulGLNG_0-1755167301628.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Shashank_Jain
Kilo Sage

@Gopal14 ,

CC : @Dr Atul G- LNG ,

 

Go to "ArticleTemplateUtil" script include and copy this code.

Keep in mind, I define two variables in starting :

 

      var KNOWN_ERROR_TEMPLATE_SYS_ID = '478034d4870023000e3dd61e36cb0b56'; // keep sys id of known error article template
        var KB_SYS_ID = 'a7e8a78bff0221009b20ffffffffff17';  // keep sys id of customer service knowledge base
 
var ArticleTemplateUtil = Class.create();
ArticleTemplateUtil.prototype = Object.extendsObject(ArticleTemplateUtilSNC, {

    getArticleTemplatesForKnowledgeBase: function(kbId, addNames) {
        var KNOWN_ERROR_TEMPLATE_SYS_ID = '478034d4870023000e3dd61e36cb0b56';
        var KB_SYS_ID = 'a7e8a78bff0221009b20ffffffffff17';

        var gr = new GlideRecord('kb_template_m2m_knowledge_base');
        gr.addQuery('kb_knowledge_base', kbId);
        gr.query();

        var templates = {};

        // Always add Standard template
        if (addNames)
            templates['kb_knowledge'] = 'Standard';
        else
            templates['kb_knowledge'] = true;

        if (!gr.hasNext()) {
            var template = new GlideRecord('kb_article_template');
            template.addActiveQuery();
            template.query();
            while (template.next()) {
                // Skip Known Error template if IT KB
                if (kbId == KB_SYS_ID && template.sys_id == KNOWN_ERROR_TEMPLATE_SYS_ID)
                    continue;

                if (addNames)
                    templates[template.child_table] = template.getDisplayValue('article_template');
                else
                    templates[template.child_table] = true;
            }
        } else {
            while (gr.next()) {
                if (gr.kb_article_template.active) {
                    // Skip Known Error template if IT KB
                    if (kbId == KB_SYS_ID && gr.kb_article_template.sys_id == KNOWN_ERROR_TEMPLATE_SYS_ID)
                        continue;

                    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'
});

 

I tried it on PDI, Removed "Known error article" template for "IT" knowledge Base.

Refer below screenshot :

Screenshot (11).pngIf this helps, please consider marking my answer as helpful/accepted — it motivates me to stay active in the community and also helps others find relevant solutions more easily.

Thank you!

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights

@Gopal14 ,

If the solution works, mark it as accepted and close the thread.

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights

@Gopal14 ,

 

If the above solution helps, please mark it as accepted and close the thread.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights