How to restore the knowledge articles from one instance to another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @msc
you can use REST API in instance B to get KB article from instance A.
Also there is a OOB knowledge scripted rest api , you can use get method for your requirement.
https://<Your instancence name>/sys_ws_definition.do?sys_id=8ad394c8db03220099f93691f0b8f584&sysparm_view=&sysparm_record_target=sys_ws_definition&sysparm_record_row=1&sysparm_record_list=nameSTARTSWITHknowledge%5EORDERBYname&sysparm_record_rows=1
If you want to created scripted rest api for your requirement. you will get guide from there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
But why is this required?
are you doing this between 2 different ServiceNow instances i.e. between 2 different companies?
You will have to use custom scripted REST API to handle this.
also check this
How to create knowledge article in ServiceNow with article state as Publish?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
We are doing this activity from commercial to fedramp related instances
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
24m ago
Hi @msc ,
you can archive with schedule job
(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();
}
})();u_source_sys_id | String (32) |
Please accept the solution and close the tried if this is helpful.
Thanks,
Rithika.ch
