Issue with getting API error code and message from action to sub flow in flow designer

Snehal13
Kilo Sage

1.  My action script is below 

(function execute(inputs, outputs) {
    
    var response = JSON.parse(inputs.response);
    outputs.responsedata.code = response.errorCode;
    outputs.responsedata.message = response.message;        

})(inputs, outputs);

So the output of action script is an object

Snehal13_0-1746978162791.png

Output of action, it's an object type

 

Snehal13_1-1746978214095.png

 

I want to get API error code and message in subflow as this - if loop to check if code is 1 or 0 but the subflow is not working. 

 

Sub flow if condition on Action-REST Step-Code data pill -   no match found

Snehal13_0-1746977924124.png

 

Why the object is not showing values under it

1 ACCEPTED SOLUTION

Robert H
Mega Sage

Hello @Snehal13 ,

 

Just defining the Object as an Output Variable is not enough.

You also need to define its properties that you are populating in the script. You do that by clicking the small (+) icon on the ResponseData output variable:

 

RobertH_0-1746981746869.png

 

You will also have to add one more line to the script:

(function execute(inputs, outputs) {
    
    var response = JSON.parse(inputs.response);
    outputs.responsedata = {}; // add this line
    outputs.responsedata.code = response.errorCode;
    outputs.responsedata.message = response.message;        

})(inputs, outputs);

 

Regards,

Robert

 

View solution in original post

7 REPLIES 7

Robert H
Mega Sage

Hello @Snehal13 ,

 

Just defining the Object as an Output Variable is not enough.

You also need to define its properties that you are populating in the script. You do that by clicking the small (+) icon on the ResponseData output variable:

 

RobertH_0-1746981746869.png

 

You will also have to add one more line to the script:

(function execute(inputs, outputs) {
    
    var response = JSON.parse(inputs.response);
    outputs.responsedata = {}; // add this line
    outputs.responsedata.code = response.errorCode;
    outputs.responsedata.message = response.message;        

})(inputs, outputs);

 

Regards,

Robert

 

Ok, Now I can see the data pill inside the object in subflow but still cant have the condition met. looks like the value from output of action is still empty

@Snehal13 

 

Your question was only about making the properties of your output object available as data pills. So you should mark it as answered.

 

If some value is empty you'll have to debug your script. Have you verified that the inputs.response property contains the expected data?

 

Regards,

Robert

I have accepted your solution from prev comment. Thanks.

 

It does.  I do get values in the below logs

 gs.log("response.errorCode="+response.errorCode);
        gs.log("response.message="+response.message);