How to restore the knowledge articles from one instance to another

msc
Tera Contributor

Hi Everyone 

 

Need your help on one of my requirement to get the knowledge articles from one instance and create or update it on another instance through schedule job. We have to get the data ( publish , retired ) from one instance and create or update it on another instance with out any information or mail to trigger the user.

 

Thanks 

 

8 REPLIES 8

ChallaR
Giga Guru

Hi @msc ,

 

you can archive with schedule  job 

Scheduled Script -
(function execute() {

  var r = new sn_ws.RESTMessageV2('KB Sync from Source', 'get');
  var response = r.execute();
  var data = JSON.parse(response.getBody()).result;

  for (var i = 0; i < data.length; i++) {

    var src=data[i];

    var kb = new GlideRecord('kb_knowledge');
    kb.addQuery('u_source_sys_id', src.sys_id); // custom field
    kb.query();

    if (kb.next()) {
      // UPDATE
      kb.setWorkflow(false); // ✅ No emails / no workflows
    } else {
      // CREATE
      kb.initialize();
      kb.setValue('u_source_sys_id', src.sys_id);
      kb.setWorkflow(false); // ✅ No emails / no workflows
    }

    kb.short_description = src.short_description;
    kb.text = src.text;
    kb.workflow_state = src.workflow_state; // published / retired

    if (kb.isNewRecord())
      kb.insert();
    else
      kb.update();

  }

})();
Add this custom field on kb_knowledge
Field name Type
u_source_sys_idString (32)

 

Please accept the solution and close the tried if this is helpful.

 

Thanks,

Rithika.ch 

msc
Tera Contributor

Hi Challa,

 

Could you please explain how we can achieve this and we have lot of sub tables data means different classes exist in kb _knowledge table. We are pulling that data to another instances

 

kumkumr
Tera Contributor

There are multiple approaches depending on your requirement. Let me walk you through all of them most common method best for Migrating a small set of articles between instances.

  1. Go to the source instance
  2. Navigate to System Update Sets → Local Update Sets
  3. Click New  Give it a name (e.g Knowledge Articles Migration)
  4. Set it as the Current Update Set
  5. Open each Knowledge Article you want to migrate
  6. Right-click the form header  Click "Add to Update Set"
  7. Once done, go to the update set  Click Complete
  8. Click Export to XML Save the XML file

On Target Instance

  1. Go to System Update Sets  Retrieved Update Sets
  2. Click Import Update Set from XML
  3. Upload the xmlfile
  4. Open the retrieved update set Click Preview
  5. Resolve any conflicts  Click Commit

 

 

kumkumr
Tera Contributor

There are multiple approaches depending on your requirement. Let me walk you through all of them most common method best for Migrating a small set of articles between instances.

  1. Go to the source instance
  2. Navigate to System Update Sets → Local Update Sets
  3. Click New  Give it a name 
  4. Set it as the Current Update Set
  5. Open each Knowledge Article you want to migrate
  6. Right-click the form header  Click "Add to Update Set"
  7. Once done, go to the update set  Click Complete
  8. Click Export to XML Save the XML file

On Target Instance

  1. Go to System Update Sets  Retrieved Update Sets
  2. Click Import Update Set from XML
  3. Upload the xmlfile
  4. Open the retrieved update set Click Preview
  5. Resolve any conflicts  Click Commit