Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to parse For Each data object.

Shidhi07
Tera Contributor

Hi,

A custom action is converting a comma-separated string to a Flow object. And this flow object is being passed into For Each and into a spoke. I've been trying to access the flow object of each iteration(shown below) to print it into the work notes.

Shidhi07_0-1749493733611.png


I tried in the below way but not working giving fd_data is undefined.

var worknotes = fd_data._9__for_each;
return worknotes;

Please anyone suggest me approach or solution.
Thank you!!

 

1 REPLY 1

ursnani
Giga Guru

Try to Convert the comma separated values into an array and then loop then For each action, i did the same with the below code

 

var arrStr = inputs.<your variable>.toString();

var strSpilt = arrStr.split(',');

outputs.finalarr = strSplit;

 

Make sure your Output for the Script is of type Array and the final Action output as String.