How to modify/update a large XML file and then import?

Jay_Shin
Kilo Contributor

Hi Experts,

I have an XML file of KB articles size around 300-400 MB.
I want to modify few field values from the XML file(eg. created by to XYZ, Created on to current date/time, view count to 0, etc).
Due to size of the file it's impossible to modify the field values manually and import.
I want to know is there any way I can import the XML by modifying the fields in it.  

Thanks in advance.

 

8 REPLIES 8

mr18
Tera Guru
Tera Guru

Hi Jay,

You can use background script

var gr = new GlideRecord("kb_knowledge");
gr.addQuery("sys_id", "<sys id of the KB article>");
gr.query();
if(gr.next()) {
gr.sys_created_by = "<sys id of the user>";
gr.sys_created_on = gs.nowDateTime();
grsetWorkflow(false);
gr.autoSysFiields(false);
gr.update();
}

Jay_Shin
Kilo Contributor

Hi this might work for a single KB article. There are many KB articles.

Thanks

You can update the query as per your requirement

sachin_namjoshi
Kilo Patron
Kilo Patron

First, you should modify data in servicenow UI forms before export.

After modification is done, you can use export, import functionality to export, import data in JSON format.

https://developer.servicenow.com/blog.do?p=/tags/export-set/

 

If you still need to export in XML format, then you need to break up XML

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/exporting-data/ta...

 

Regards,

Sachin