Export Update Set

Surbhi16
Tera Contributor

Hi Experts,

 

Need assistance on below:

1. Export Update set using a Script and then automatically send that XML export as an attachment with an email to an user.

Kindly assist!

 

Regards,

Surbhi

1 ACCEPTED SOLUTION

ersureshbe
Giga Sage
Giga Sage

Hi, 

I recommend to use ?UNL& to download the xml. ie.,

https://dev123.service-now.com/sys_update_set.do%3Fsys_id%3D29042a001ba86510f40fa68a234bcbae%26

https://dev123.service-now.com/sys_update_set.do?UNL&sys_id%3D'sys_idofUpdateSet'%26

 

This is OOB feature. You can use and download as xml file.

Regards,
Suresh.

View solution in original post

13 REPLIES 13

To share the update set with the target instance where we cannot connect two instances together neither through Web Service nor through Update Source.

Hence we thought of sending this over an email. Any direction from your end on how to proceed further with this requirement.

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi @Surbhi16 ,

                           In ServiceNow, we can export an update set using the "sys_update_xml.getXML()" API. So you use it as attachment while sending Email. Or you can use it in BR as below

// Get the update set to export
var updateSet = new GlideRecord('sys_update_set');
updateSet.get('YOUR_UPDATE_SET_SYS_ID');

// Export the update set as XML
var xml = new XMLDocument();
xml.parseXML(updateSet.getXML().getXML());
var updateSetXML = xml.getContent();

// Create the email and attach the exported XML
var emailSend = new GlideEmailOutbound();
emailSend.setSubject('Update Set Export');
emailSend.setPlainTextBody('Attached is the exported update set');
emailSend.addAttachment('update_set.xml', 'application/xml', updateSetXML);
emailSend.addRecipient('RECIPIENT_EMAIL_ADDRESS');
emailSend.send();

Kindly mark correct and helpful if applicable

Hi @Chetan Mahajan 

Thank you so much for your reply. I am getting as undefined and also error as "

Can't find method com.glide.notification.Email.addAttachment(string,string,undefined). (null.null.script; line 15)

"

Can you please assist me if I am doing anything incorrect here based on the script you shared.

 

Regards,

Surabhi

 

Hi @Chetan Mahajan 

The code shared above is not working and giving me as "undefined".

My version of code tried is as below:

var updateSet = new GlideRecord('sys_update_set');
updateSet.get('e6f220981b302510a99ea8e5604bcbbf');
gs.info(updateSet.getXML());

// Export the update set as XML
var xml = new XMLDocument();
xml.parseXML(updateSet.getXML().getXML());
//gs.info(xml);
var updateSetXML = xml.getContent();

//gs.info(updateSetXML);

Hi @Chetan Mahajan 

Thank you for your response. Above code is not working and is giving as undefined when used.

Can you please help on how to get this working.