This widget seems to only have just the startup function so that is the only event state we have to deal with.
If you go into your WAB install folder/client/stemapp/widgets/geoprocessing. If you open the Widget.js file in your text editor of choice. You will notice on line 49, there is "startup: function()". This function ends around line 129.
If you open the widget.html file, you will see around line 12, the button that calls "_onExecuteClick". You just need to add this function to the end of the startup function so that it fires off without any user interaction.
The startup function, with the change, would look like the following with the call to execute the GP at the end.
startup: function(){
this.inherited(arguments);
if(!this.config.taskUrl){
html.setStyle(this.toolNode, 'display', 'none');
html.setStyle(this.errorNode, 'display', '');
return;
}
this.inputNodes = [];
this.drawTools = [];
//each result will be displayed by dijit
this.resultNodes = [];
this.resultLayers = [];
editorManager.setMap(this.map);
editorManager.setNls(this.nls);
resultRendererManager.setMap(this.map);
resultRendererManager.setNls(this.nls);
this.gp = new Geoprocessor(this.config.taskUrl);
this.gp.setOutSpatialReference(this.map.spatialReference);
if(this.config.updateDelay){
this.gp.setUpdateDelay(this.config.updateDelay);
}
this.tab = new TabContainer({
tabs: [{
title: this.nls.input,
content: this.inputPaneNode
}, {
title: this.nls.output,
content: this.outputPaneNode
}],
selected: this.nls.input
});
this.tab.placeAt(this.domNode);
this.tab.startup();
this.loading = new LoadingIndicator({
hidden: true
}, this.loadingNode);
this.loading.startup();
//Fires when a synchronous GP task is completed
this.own(on(this.gp, 'execute-complete', lang.hitch(this, this.onExecuteComplete)));
//Fires when an asynchronous GP task using submitJob is complete.
this.own(on(this.gp, 'job-complete', lang.hitch(this, this.onJobComplete)));
this.own(on(this.gp, 'job-cancel', lang.hitch(this, this.onJonCancel)));
//Fires when a job status update is available.
this.own(on(this.gp, 'status-update', lang.hitch(this, this.onStatusUpdate)));
//Fires when the result of an asynchronous GP task execution is available.
this.own(on(this.gp, 'get-result-data-complete',
lang.hitch(this, this.onGetResultDataComplate)));
//Fires when a map image is generated by invoking the getResultImage method.
this.own(on(this.gp, 'get-result-image-layer-complete',
lang.hitch(this, this.onGetResultImageLayerComplate)));
this.own(on(this.gp, 'error', lang.hitch(this, this.onError)));
html.setAttr(this.helpLinkNode, 'href', this.config.helpUrl);
this._generateUniqueID();
if(!("serverInfo" in this.config)){
//Load gp server info if it does not exist.
gputils.getServiceDescription(this.config.taskUrl).then(lang.hitch(this,
function(taskInfo){
this.config.serverInfo = taskInfo.serverInfo;
this._createInputNodes();
}));
}else{
this._createInputNodes();
}
this._onExecuteClick();
},