How to get response code and response message from action into subflow that called the action

Snehal13
Kilo Sage

I have a subflow that calls an action by sending 4 params. The action has REST step to make an API post call to a 3rd party platform and get a response - errorCode and message.

 

I wan to get this errorCode and message into my subflow so that the if else loop can close existing task record in errorCode is success or create an incident if errorCode is failure.

 

 

I have the action output variable defined from the script but unable to get the value in my if loop in subflow. What is missing

5 REPLIES 5

DanielCordick
Mega Patron
Mega Patron

 

You should be able to pass the response fromt he REST step into the outputs of the action, or into other steps within the action

 

 

DanielCordick_0-1746889382783.png

 

OK and how to use this output in my subflow. I mean the if condition if error code in response is 0, update sc task. If error code in response is 1, update incident 

When you test the action,

You will see what’s getting set in the the pills of the rest step.. those pills can become whatever output variable you set. 

so if you create an output of response code, Use the response code pill. 

 

when in the subflow you can select the pill from your action to use in your IF statement 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/yokohama/servicenow_application_devel...

 

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

 

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