Catalog Script GlideAjax calling script include subflow result.getOutputs() returns null

yschulman
Tera Contributor

I have a catalog item that on change of a field is to use GlideAjax to call a script include:

 

 

var ajax = new GlideAjax('Troux_Subflows') ;
	ajax.addParam('sysparm_name','getTrouxCloudLZ');
	ajax.addParam('sysparm_lzid',"lzid .eq " + newValue);
	ajax.getXML(HelloWorldParse);
 
	function HelloWorldParse(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		alert(answer); 
		console.log(answer);
	}

 

 

The getTrouxCloudLZ script calls a subflow:

 

 

var Troux_Subflows = Class.create();
Troux_Subflows.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	getTrouxCloudLZ:function(){
		var inputs = {};
		inputs['lzid'] = this.getParameter('sysparm_lzid'); // String 
		// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
		var result = sn_fd.FlowAPI.getRunner().subflow('global.troux_cloudlandingzone_check').inForeground().withInputs(inputs).run();

		//this is causing the issue for returning null
		var outputs = result.getOutputs();

		// Get Outputs:
		return JSON.stringify(outputs['lzrecord']); // Array.Object
	},

    type: 'Troux_Subflows'
});

 

 

at the point in which the script calls result.getOutputs() the return value will always be null.
I know the subflow is being triggered because I can see in the subflow executions it is behaving correctly.

If I put a return inputs['lzid'] any place before the result.getOutputs() then I will get the expected value back.
There is something about getOutputs() that is causing the function to return null.
How do I figure this out so that I can return the results to the Catalog Script?

5 REPLIES 5

I did follow the example however I am retrieving the data via an Action REST process that then uses the JSON Parse step.  That is pasted back into the Subflow.  The only way I have been able to get the result.getOutputs() function to work is that in the in Subflow I first do a function to retrieve the first record and then do a foreach loop to pass back specific object values from the item into specific output string variables.  It is tedious but anytime I include the array.object as one of the output variables (regardless if I call them from my script include) the entire output function fails and returns null for all outputs variables.