Flow Designer Array.object for each

Vejdis
Tera Expert

Hello!

I'm testing abit with the flow designer but I can't iterate a array of objects.

The flow looks as following images

test_flow.jpg

This is the flow, it's very simple. Action 1 creates an array and puts it in output variable artlist, format Array.Object.

But when I try to iterate through them with the for each item in the created output variable (artlist) I get an error, see next image.

test_flow_error.jpg

 

 It says that it iterated 0 of 0 in size, but the array should be 2. And In the first step I can check the length and it is 2.

Furthermore when you open the for each step in the error it says "Type" Records, shouldn't this be objects?

 

When I check the flow logs I get the following:

 

test_flow_error2.jpg

 

I don't even get to the second step but I will paste it anyway. It should take the object, and try to print the attributes of it.

 

test_printarray_1.jpg

 

test_printarray_2.jpg

 

I get the same error if I use Array.string and change all inputs/outputs from objects to string.

 

Any help will be much appreciated

 

EDIT: All images in order

Flow

test_flow.jpg

 Step 1

test_create_array1.jpg

 

test_create_array2.jpg

 Step 2

test_printarray_1.jpg

 

test_printarray_2.jpg

 

4 REPLIES 4

nsp
Tera Contributor

I hope you are using json parser in action and if possible can you share the payload .and mention what properties you are trying to access

Does it matter what I'm trying to access since the error appears in the for each?

What do you mean with the json parser? I'm creating the array manually. I added images of all steps in the first post 

JSON.parse(manually_created_array);

 

MohammedAsK
Tera Contributor

https://www.servicenow.com/community/developer-forum/array-object-not-passed-into-for-each-loop/m-p/...

 

I am having sort of similar issue, for each item it is showing 0 of 0, i tried JSON.parse, converted into string and splitting into array, changing the payload itself.

But all in vain, in the end, I added a Log Action, used the script to loop through the JSON payload and did the work as of now.