Backing up Update Sets In Progress Before a Clone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2010 02:01 PM
With the release of Winter 2010, I would like to know if it is possible to backup and restore an update set that is in progress.
Our Dev environment is in need of a fresh clone, however I have several update sets in various stages of development. Using the new "Export to XML" form UI Action, I have to change the update set to completed and it shows up in the import and "loaded" (effectively retrieving it from another system.) The problem is, I cannot continue development on that update set after a clone.
Recommendations?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2010 07:21 AM
The Export to XML UI Action was built specifically to export completed update sets. It uses a Script Include called "ExportWithRelatedLists" that does perform the function you need. If you invoke that Script Include, you should be able to generate an XML of the Update Set even if it's in progress.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2010 07:26 AM
Guy,
Thank you for the response. I validated the script include is there, but don't exactly know what to do with it.
Do you have an example of how this would be done on an update set that it is in progress? I'd like to test it from dev to test to ensure it will work after I clone dev. A step-by-step would be wonderful.
Thanks
-Chuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2011 02:32 PM
ctomasi
Hi Chuck,
I know it's been a while and you probably have figured out how to this but I thought I include some links and code for the benefit of others 🙂
Basically you'll need to setup a processor which is called by usually a UI action. There's an excellent example on SNCguru to export workflows with related lists:
http://www.servicenowguru.com/graphical-workflow/exporting-graphical-workflows/
Another example which is out-of-box functionality is the 'ExportUpdateSet' processor which is called by the 'Export to XML' UI Action:
This is the code for the 'Export to XML' UI Action:
var retrievedUpdateSet = new GlideRecord('sys_remote_update_set');
retrievedUpdateSet.initialize();
retrievedUpdateSet.description = current.description;
retrievedUpdateSet.name = current.name;
retrievedUpdateSet.release_date = current.release_date;
retrievedUpdateSet.remote_sys_id = current.sys_id;
retrievedUpdateSet.state = "loaded";
var sysid = retrievedUpdateSet.insert();
var update = new GlideRecord('sys_update_xml');
update.addQuery('update_set', current.sys_id);
update.query();
while(update.next()) {
update.remote_update_set = retrievedUpdateSet.sys_id
update.update_set = '';
update.insert();
}
action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true");
....which calls the 'ExportUpdateSet' processor:
var sysid = g_request.getParameter('sysparm_sys_id');
var exporter = new ExportWithRelatedLists('sys_remote_update_set', sysid);
exporter.addRelatedList('sys_update_xml', 'remote_update_set');
exporter.exportRecords(g_response);
var del = g_request.getParameter('sysparm_delete_when_done');
if (del == "true") {
var ugr = new GlideRecord("sys_remote_update_set");
ugr.addQuery("sys_id", sysid);
ugr.query();
if (ugr.next()) {
ugr.deleteRecord();
}
}
Notice how both processors (the one from SNCguru, WorkFlow Export, and the one from OOB system, ExportUpdateSet) refernece the aforementioned script include 'ExportWithRelatedLists'.
Hopefully using these examples you should be able to cobble something together 🙂