Issue with getting a value from an object

Hi there fellow Wapplers,

I have this strange issue where I cannot seem to get a specific value from an object within an array. I created a test setup that is easy to replicate.

With this sc file it works fine:
scsetobject
You can see that on opening the sc file in browser I get a value for nameofobject:
nameofobject

But when I create an Array List with multiple of these objects and perform a .where query on the array, I CAN get the whole object, but I can’t seem to get the value for object.file.name.

Here is my sc:
scwitharrayobjects

And in the results the nameofobject is not present:

object.file.name returns nothing.

What am i missing?

Any help is greatly appreciated.

ps here is the code for the server connect file

while_test.zip (899 Bytes)

bg

Jelle

I think perhaps a flaw in your logic. You are trying to do a groupBy on file, but that is not an array. object is the array.

Thanks for the response, Ken. Question remains how does one get the value for object.file.name.

This is just one of my many attempts to access this value in the object.

try
Set Value nameofobject = {{object.groupBy(‘file’).keys()}}

Your object is returning an array, so if that where clause will always return one item, then use object[0].file.name

1 Like

Thanks, Ken! :tada: :grin: :+1: That is indeed it. So the lesson here is, because object opens up with the , it returns an array. And with this [0] you choose to only return the first item in the array, correct?

Correct. Arrays are signified by the square brackets [ ] and you can reference any item in an array by its index number which uses zero based counting. So items[0] gives you the first item, items[1] gets the second item, etc.

2 Likes