SNOW – Migrating KB articles content with a script.
Posted On October 6, 2017
This method is also applicable for moving content from the v2 ‘Knowledge’ knowledge base to the target v3 KBs.
- Navigate to Knowledge >Administration > Knowledge Bases.
- Click on a knowledge base Titleto open a knowledge base.
- Right click the header barand select Copy sys_id.
- Copy and paste the sys_id to a text file.
- Navigate to Knowledge >Administration > Knowledge Bases.
- Click on a knowledge base Titleto open a knowledge base.
- Open an article that already has the desired category in the target knowledge base.
- Click the information icon next to the Category field.
- Right click the header barand choose Copy sys_id.
- Copy and paste the sys_idinto a notepad.
- Navigate to System Definition > Scripts – Background.
- Paste the following script into Run script (JavaScript executed on server) textbox:
- Replace TARGET_KB_SYS_IDwith the sys_id copied in step 4
- Replace TARGET_KB_CATEGORYwith the sys_id copied in step 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
varTARGET_KB_SYS_ID = 'a7e8a78bff0221009b20ffffffffff17'; varTARGET_KB_CATEGORY = '4008ed12ff0131009b20ffffffffffef'; varKB_ARTICLES_TO_MOVE = [ "KB0000009",//sample KB IDs "KB0000006" ]; for(vari = 0; i < KB_ARTICLES_TO_MOVE.length; i++) { moveKBArticle(KB_ARTICLES_TO_MOVE[i]); } functionmoveKBArticle(kbNumber) { varkb= newGlideRecord('kb_knowledge'); kb.setWorkflow(false); kb.addQuery('number',kbNumber); kb.query(); if (kb.next()) { kb.kb_knowledge_base = TARGET_KB_SYS_ID; kb.kb_category = TARGET_KB_CATEGORY; kb.update(); gs.print('Updated '+ kbNumber); } else{ s.print('Did not find '+ kbNumber); } } |