Script to export reports to individual XML Files

madhuv
Tera Contributor

Hi ,

We have a requirement to delete old unused reports (10000+). But Management wants to keep the back up of old reports in the individual XML files, lets say if 100 reports are there , they want to have 100 xml files of each report. Do we have any bulk export mechanism or any scripting to keep take them all individually and save them with their respective names, instead of taking all into XML.?

 

Regards

Madhu

9 REPLIES 9

Yash Agrawal1
Tera Guru

Hello MAdhu,

Please go through the document provided by ServiceNow for exporting Bulk Data:

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

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

Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.

Regards

Yash.K.Agrawal

Hello Yash,

 

Thanks for your response. But the provided links does not help as what we are looking is to export  them as individual files not into single file.

 

Regards

Madhu

Hi Madhu,

one thing you can try is this using your javascript executor

when it runs it will ask you whether to save or open the file.

you try this in chrome so that it auto-downloads

Short cut - Ctrl + Shift + Alt + J

downloadFiles();

function downloadFiles(){
var sysIdArray = ['sys_id1','sys_id2']; // give here those 100 record sys_ids

for(var i=0;i<sysIdArray.length;i++){
var gr = new GlideRecord('tableName');
gr.addQuery('sys_id', sysIdArray[i]);
gr.query();
if(gr.next()){
var url = '/tableName_list.do?XML&sysparm_query=sys_id=' + sysIdArray[i];
window.open(url);
}
}
}

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

When I tried to do it 

var url = '/tableName_list.do?XML&sysparm_query=sys_id=xxxxxxx';
window.open(url);

Chrome open the xml file in a new tab instead of asking me to download it