Name
global.PatternExporterAjax
Description
This PatternExporterAjax script is a Proxy between Client side and server
Script
var PatternExporterAjax = Class.create();
PatternExporterAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
process: function() {
var CANCEL_EXPORT_PROCESS = "cancelExport";
var PATTERN_BASIC_EXPORT = "basic_export";
var PATTERN_ADVANCED_EXPORT = "advanced_export";
var func = this.getParameter("sysparm_ajax_processor_function");
var trackerId = this.getParameter("sysparm_ajax_processor_tracker_id");
var patternList = this.getParameter("sysparm_ajax_processor_pattern_list");
if (func == CANCEL_EXPORT_PROCESS)
return this.sendCancelSignal(trackerId);
if (func == PATTERN_BASIC_EXPORT)
return this.startPatternBasicExport(patternList);
if (func == PATTERN_ADVANCED_EXPORT)
return this.startPatternAdvancedExport(patternList);
},
startPatternBasicExport: function(patternList) {
return this._startPatternExport(GlideSysMessage.format("Exporting patterns with their references."),'exportPatternBasic',patternList);
},
startPatternAdvancedExport: function(patternList) {
return this._startPatternExport(GlideSysMessage.format("Exporting patterns with their references and related CMDB items."),'exportPatternAdvanced',patternList);
},
_startPatternExport: function(progressName, functionToExecute, patternList) {
// Setup and start the progress worker
var worker = new GlideScriptedHierarchicalWorker();
worker.setProgressName(progressName);
worker.setScriptIncludeName('PatternExporter');
worker.setScriptIncludeMethod(functionToExecute);
worker.putMethodArg('patternList', patternList);
worker.setBackground(true);
worker.setCannotCancel(true);
worker.start();
return worker.getProgressID();
},
completeExport: function(exportUpdateSetId) {
UpdateSetPublisher.deleteAllUpdateSets(exportUpdateSetId);
},
// send the cancel by adding the cancel signal into the pattern export tracker
// result, so that the update set progress worker will catch it
sendCancelSignal: function(trackerId) {
var tracker = SNC.GlideExecutionTracker.getBySysID(trackerId);
tracker.updateMessage("Canceling pattern export prcess...");
result = {'export_cancel_requested': 'true'};
tracker.updateResult(result);
return;
},
type: "PatternExporterAjax"
});
Sys ID
79b27025938203008a2e35bb357ffb2b