Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Migrating knowledge articles between Knowledge Bases via a script - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Migrating knowledge articles between Knowledge Bases via a script
KB0852780

Migrating knowledge articles between Knowledge Bases via a script


9132 Views Last updated : Jun 11, 2025 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Summary

You can move articles from one knowledge base to another while changing the category matching the target knowledge base.

Release

All releases.

Instructions

This is an example and should be modified to support other migration scenarios. 

  1. Navigate to Knowledge >Administration > Knowledge Bases.
  2. Click on a knowledge base Title to open a knowledge base.
  3. Right click the header bar and select Copy sys_id. 
  4. Copy and paste the sys_id to a text file.
  5. Navigate to Knowledge >Administration > Knowledge Bases.
  6. Click on a knowledge base Title to open a knowledge base.
  7. Open an article that already has the desired category in the target knowledge base. 
  8. Click the information icon next to the Category field.
  9. Right click the header bar and choose Copy sys_id. 
  10. Copy and paste the sys_id into a notepad.
  11. Navigate to System Definition > Scripts – Background.
  12. Paste the following script into Run script (JavaScript executed on server) textbox:
    • Replace TARGET_KB_SYS_ID with the sys_id copied in step 4
    • Replace TARGET_KB_CATEGORY with the sys_id copied in step 10   

var TARGET_KB_SYS_ID = 'a7e8a78bff0221009b20ffffffffff17';
var TARGET_KB_CATEGORY = '4008ed12ff0131009b20ffffffffffef';
var KB_ARTICLES_TO_MOVE = [
  "KB0000009", //sample KB numbers
    "KB0000006"
];

for (var i = 0; i < KB_ARTICLES_TO_MOVE.length; i++) {
    moveKBArticle(KB_ARTICLES_TO_MOVE[i]);
}

function moveKBArticle(kbNumber) {
    var kb = new GlideRecord('kb_knowledge');
kb.autoSysFields(false);
    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.info('Moved ' + kbNumber + ' to Knowledge Base ' + TARGET_KB_SYS_ID);
    } else {
      gs.info('Did not find ' + kbNumber);
    }
}

Related Links

Note that extra care needs to be taken when the Knowledge Management Article Versioning feature is active as all versions of an article would need to be moved.


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • Cookie Preferences
  • © 2025 ServiceNow. All rights reserved.
We use cookies on this site to improve your browsing experience, analyze individualized usage and website traffic, tailor content to your preferences, and make your interactions with our website more meaningful. To learn more about the cookies we use and how you can change your preferences, please read our Cookie Policy and visit our Cookie Preference Manager. By clicking “Accept and Proceed,” closing this banner or continuing to browse this site, you consent to the use of cookies.