Flow designer error : JSON string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:38 AM
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 06:15 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:36 PM
@Averyy Update the script as follows and see if it works.
var payload = JSON.parse(fd_data.trigger.payload);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 12:57 AM
Thank you! This created an error when testing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 08:28 PM
Hello @Averyy
If possible can you share snapshot of flow and snapshot of payload field & payload data ...??
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 07:11 AM
Hello all apologies when I created this post I left out a lot of info. I have since recreated the post.