- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 07:55 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 05:37 AM - edited 01-31-2023 05:39 AM
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.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 07:57 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 11:20 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 11:40 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 02:52 AM
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.