Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to transfer knowledge articles from one knowledge Base to another knowledge base?

Jayant Balyan
Tera Contributor

How can i transfer articles from one knowledge base to another knowledge base? What is the best practice for this?

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage

Hi @Jayant Balyan ,

 

You can follow the steps mentioned in Servicenow support article please find the article below,

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0852780 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

View solution in original post

5 REPLIES 5

yasin1
Tera Contributor

I think you can use this script;

var gr = new GlideRecord("kb_knowledge");
gr.addQuery("kb_knowledge_base","old_knowledge_base_sys_id");
gr.query();
while(gr.next()){
gr.setValue("kb_knowledge_base=<new_knowledge_base_sys_id");
gr.update();
}

 

Or you can set from knowledge articles list via update all option.

 

swathisarang98
Giga Sage

Hi @Jayant Balyan ,

 

You can follow the steps mentioned in Servicenow support article please find the article below,

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0852780 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Hi @swathisarang98 ,

 

I tried this script, but it worked only for Version 1 Knowledge articles. for some Articles with V2 and V3 it did not include. how can i include logic so that it works for all the version articles.

 

Thanks & Regards,

Gautami

 

@SodadasiG  try doing the below ,

 

Simply change the 'moveKBArticle' function to this in the previous code from servicenow  support


function moveKBArticle(kbNumber) {
var kb = new GlideRecord('kb_knowledge');
kb.autoSysFields(false);
kb.setWorkflow(false);
kb.addQuery('number', kbNumber);
kb.query();
if (!kb.hasNext()){
gs.info('Did not find ' + kbNumber);

return;
}
while (kb.next()) {
kb.kb_knowledge_base = TARGET_KB_SYS_ID;
kb.kb_category = TARGET_KB_CATEGORY;
kb.update();
gs.info('Moved ' + kbNumber + ' to Knowledge Base ' + TARGET_KB_SYS_ID);
}
}

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang