Flow designer error : JSON string

Averyy
Tera Contributor

Hello,

 

I am working on a flow to be triggered when a supervisor approves the submission of a document from a new hire. 

I keep getting this JSON error

 

Any suggestions? (I am not the most exp dev at the moment)

 

Averyy_0-1705851459294.png

 

Averyy_1-1705851495315.png

 

9 REPLIES 9

-O-
Kilo Patron
Kilo Patron

JSON.parse expects a string as parameter, and fd_data.trigger.current.payload (assuming such a field exists) is not a string, but an object (of "type" GlideElement).

This situation makes JSON.parse freak out.

 

All in all I'd try

var payload = fd_data.trigger.current.payload.nil() ?
	{} :
	JSON.parse(fd_data.trigger.current.payload.toString());

again assuming field/column payload does exist and it contains a valid JSON.

This will make payload end up being either an "empty" object or the object in the JSON.

Sandeep Rajput
Tera Patron
Tera Patron

@Averyy Update the script as follows and see if it works.

 

var payload = JSON.parse(fd_data.trigger.payload);

Thank you! This created an error when testing

Vishal Birajdar
Giga Sage

Hello @Averyy 

 

If possible can you share snapshot of flow and snapshot of payload field & payload data ...?? 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Averyy
Tera Contributor

Hello all apologies when I created this post I left out a lot of info. I have since recreated the post.

 

https://www.servicenow.com/community/hrsd-forum/flow-designer-error-json-string-quot-remake-quot/td-...