Manual Error Evaluation in Flow Designer

Anubhav24
Mega Sage
Mega Sage

Hi All,

I have a Flow Action where I have script step which is returning the JSON to be sent to third party,

Now my scenario is like if the JSON is empty like below what should I mention manually in the if condition input box in the below screenshot which matches the condition I have built using the data pill.

Sample Empty JSON Returned is :

{"tags":[null]}

Anubhav24_0-1741175403794.png

 

In my script I am evaluating the empty as below : 

if(JSON.stringify(outputs.requestbody).length === 0 || '{}')
{
gs.info('No request to be sent '+outputs.requestbody);
}
 
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Anubhav24

empty JSON can be due to multiple reasons

1) API failure and you didn't get any response

OR

2) API worked but 3rd party sent nothing

So you can use the REST API http status inside that IF for handling the error

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

@Anubhav24 

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

@Anubhav24 

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