JSON Update Record Error

tomaslindev
Mega Guru

Hi everyone,
I created a subflow that returns a JSON but it doesn't recognize it in the main flow.

I've changed the output to string type, but it doesn't seem to work. Any ideas?

Thank you very much, and best regards.

 

tomaslindev_0-1753974342512.png

 

tomaslindev_2-1753974412829.png

 

 

 

tomaslindev_1-1753974376847.png

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@tomaslindev 

I could see you are grabbing flow_var which means flow variable and not subflow output

Things to check

1) did the subflow gave correct json string as output when flow executed?

2) ensure subflow has output of type string and not JSON

3) did you use correct subflow output variable name in your script?

It should be something like this

var subflowoutput = fd_data._4__testing_mrvs_subflow.myjsonstring;
Select the subflow step and then add dot and then it will show the output variable name
AnkurBawiskar_0-1753975550910.pngAnkurBawiskar_1-1753975591491.png

 

AnkurBawiskar_2-1753975624437.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

John Gilmore
Giga Guru

Could be a couple of things.

Based on you screen shots fd_data.flow_variable.output_validation may not be valid. Verify the name of the flow variable.

It appears based on your output that you may not be formatting the output properly for what you are trying to do. Try formatting the output as an array of objects by enclosing it in brackets []. This may then require a change to the code in order to retrieve u_resolution_code_category.

var rcc = JSON.parse(fd_data.flow_var.output_validation);

if (rcc[0].u_resolution_code_category)
	return rcc[0].u_resolution_code_category;
else
	return '';

Ankur Bawiskar
Tera Patron
Tera Patron

@tomaslindev 

I could see you are grabbing flow_var which means flow variable and not subflow output

Things to check

1) did the subflow gave correct json string as output when flow executed?

2) ensure subflow has output of type string and not JSON

3) did you use correct subflow output variable name in your script?

It should be something like this

var subflowoutput = fd_data._4__testing_mrvs_subflow.myjsonstring;
Select the subflow step and then add dot and then it will show the output variable name
AnkurBawiskar_0-1753975550910.pngAnkurBawiskar_1-1753975591491.png

 

AnkurBawiskar_2-1753975624437.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@tomaslindev 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader