flow designer - custom actions

Rahul84
Tera Contributor

hello Developers,

 

I am getting this below response from one of the API call which I am doing through the flow action.

Below is the response body..

{"result":[{"sys_id":"a1861bdcd7011200f2d224837e610328","sys_updated_by":"admin","sys_created_on":"2023-10-05 16:58:55","sys_mod_count":"1","sys_updated_on":"2023-10-05 16:58:55","sys_tags":"","user":"506c0f9cd7011200f2d224837e61030f","sys_created_by":"admin","group":"0a52d3dcd7011200f2d224837e6103f2"}]}

 

Ask is I want to fecth the sys_id from the response body and pass this as an input to other custom flow action.

 

Please  help me how I can fetch the sys_id from the above response so that I can pass this an input to other flow action..

6 REPLIES 6

Uttkarsh S
Tera Contributor

Hi @Rahul84 ,

 

If the structure of the response body is always the same then you can use something like this:

 

responseBody.result[0].sys_id

 

 

Please mark the answer "Correct" or "Helpful", if it helps your case.

Cheers,

Uttkarsh

Amit Verma
Kilo Patron
Kilo Patron

Hi @Rahul84 

 

Try below script approach :

 

var parsedJson = JSON.parse(jsonString); //Assuming jsonString variable hold your API JSON Response
return parsedJson.result[0].sys_id;

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Thanks @Amit Verma  for the reply..
so where do you suggest me to use the script step to get the sys_id from the response body of 1 custom flow action which I want to use as an input to other action..

@Rahul84 

 

You can make use of Script Step in your custom action itself. After you are done with the API call step, take the output JSON in one of the step output variable and pass it to the Script Step as an input. Inside the Script step, make use of the script I provided. 

 

If you could share some screenshots, I will be able to visualize and assist in a better way.

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.