Script step output variable value not passing to custom action output variable in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2025 11:31 PM
Hi,
I have an issue. In flow designer, there is a script step in one custom action, where there is output variable called "object_value" (type object). And I am populating it in script step using outputs.object_value. After populating it, I have converted it into text value using JSON.stringify() and tried to print it in logs using gs.error(), then the key-value pairs are getting printed correctly.
So later, I am passing it to the custom action Output Variable called "objectValue" (type object). Now after publishing this custom action. If I try to access this object in flow designer (outside of the custom action) using Log statements. Then the object is getting printed like [Object object], but if I use JSON.stringify() method and print it.. it is just returning empty "{}" without any key-value pairs. Even if I try to access keys and values using methods like Object.keys(object_value), but it is still returning nothing.
Please help me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 01:04 AM
Did you check what output that Action gave?
very difficult to help with limited details.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 01:14 AM
@Ankur Bawiskar ,
The custom action is returning "object" as output, I don't know whether it is Object (with key-values pairs) or Object (without key-value pairs). That's why I have added log statement to stringify() and check whether data is there or not in the object, but it is returning just "{}" as mentioned in above screenshot. the object also returning as mentioned in above screenshot in logs.
But in the script step of the custom action. If I add stringify() method and print it, then it is showing all key-value pairs.
But Outside the custom action, in flow log statement it is just showing {}.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 01:19 AM
are you returning JSON from your custom action?
If yes then simply use this logic to check if the object is empty or not
try this
obj.toString().equals("{}");
refer this
How to Check if an Object is Empty in JavaScript – JS Java isEmpty Equivalent
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 01:23 AM
@Ankur Bawiskar, I am returning "Object" from custom action with type "object" (not json). And If I use JSON.stringify(object_value), it is showing {} only.
I don't know why it is missing. please help me with this
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 01:28 AM
Also, the Object.keys(object_value).length is retuning 0
Thank you
