Using JSON Parser on Array.Object in Flow Designer

TramaineM
Kilo Sage

Hello,

I recently created an Action in Flow Designer that uses JSON Parser to get some custom field variables on a JSON. This worked great and I was able to get my output variables. However, there were a few more custom fields that I needed to have an output variable for and it's not letting me since its in an Array.Object. 

I'm not good at scripting but I created a Script Step to get these fields but its not working. 

I've tried making the input variable the payload and going straight to the array.object data pill. When making the input the array.object data pill, it gives me an "Error: u,Detail: Unexpected token: u" when doing the test. When making the input the root payload from the JSON Parser step, it gives me an "Error: o,Detail: Unexpected token: o". 

 

19 REPLIES 19

Hi Sivaranjani,

 

(function execute(inputs, outputs) {

if (inputs.step_input_status_code == '200') {

var responseObj = JSON.parse(inputs.step_input_response_body);


outputs.step_output_statusid = responseObj.value.user_lo_status_id;
outputs.step_output_createddt = responseObj.value.user_lo_create_dt;
outputs.step_output_lastused = responseObj.value._last_touched_dt_utc;


}

})(inputs, outputs);

 

 

Below is the output variables am trying to populate based on the response body.

find_real_file.png

 

Please find the response body-  From the below output i need to get the "user_lo_status_id" as output. When i am trying to parse the output its showing empty. Could you please check once.

 

Thanks in advance.

find_real_file.png

Try 

var responseObj_string = JSON.stringify(inputs.step_input_response_body);

var responseObj = JSON.parse(responseObj_string);

outputs.step_output_statusid = responseObj.value.user_lo_status_id;

Siva21
Giga Contributor

Hi,
Please let me know if you were able to get this working.
Thanks,
Sivaranjani

Shouldn't be posting a new question to a thread that's a year old.

The original question is with Paris version and I thought there was a bug with array objects that is now fixed in the newer version.

That is, the content of the original question and replies probably are different because I have it working in my San Diego instance. Nevertheless, I won't reply in this thread because it'll mix the contents with different ServiceNow versions and make it more difficult for others.

I have missed the JSON PATH with is value[0] instead i have used only value. This has caused me the error. Thanks for your help