Catalog Script GlideAjax calling script include subflow result.getOutputs() returns null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2023 03:12 PM - edited 10-14-2023 03:13 PM
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?
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 07:19 AM
Hi @yschulman ,
Have you copied this code snippet from the flow directly??? if not please do
do you have outputs defined in your subflow, i would also check whats the outputs while trigger this script by going into the flow.
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 11:17 AM
@yschulman Since the output is an array of objects, it seems that it has not been configured correctly inside your flow/action. Please refer to the document https://docs.servicenow.com/bundle/sandiego-application-development/page/administer/flow-designer/ta... here on this page, steps are laid out from point #18 onwards which talks about assigning complex objects to an Array.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 06:01 AM
It appears there is an issue with having an output that is configured as an array.object. When I removed that type of output from the subflow the result.getOutputs() function works and I get all the other outputs from the subflow. Once I add an output with that type of array.object then the result.getOutputs() function fails and returns null.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 10:06 AM
@yschulman Did you try with the steps I suggested in my previous response. Give it a shot, once the complex object in the output variable is configured correctly you will start getting the correct response.