185
Views
4
Comments
Solved
Why is this list saying it's empty when I can see data in it?
Question
Application Type
Reactive

I am trying to return a list, the items of which are also smaller lists. As you can see in the screenshot, I attempted to return the parent list with only one child (the name "Stewie" and 3 roles, each with the value of "1"). However, when I try displaying this in a list, the widget doesn't show up. I debugged it and found the attached image's results, which clearly shows that the values are there, but the parent list says that empty is true and that the length is 0. I'm not sure how to fix this or get it to show up.


Screenshot 2022-09-07 005016.png
2021-06-21 12-37-59
Wei Zhu
Solution

This is expected behaviour.
It seems you are confused with Current property of List.

Usually we use Current  in For Loop to get / assign value of current element of the List.
If we use Current without For Loop, then it is the First element of List.
If  it is an empty List, then Current is just an empty element.

About your issue, even you assign value to Current.Play, List itself are still empty List.
So you need 
1. Define an PlayerWithThreeRoles Type Variable Element
2. Assign value to Player of Element
3. Add Role to Element
4. Append Element to List.

 

Regards
Wei

UserImage.jpg
Joseph Kuhn

Thank you! This fixed it and is returning what I wanted.

Following this, I have one more question. As you might have seen in the OML, I'm passing the Role Identifier in the Roles list, which is why it's returning three "1"s. I'm storing these values in an entity, but I'm currently serializing the three values because I can't figure out how to input them to the CreatePlayersWithRoles action in RandomizeRolesOnClick. I would like to create an aggregate with these roles, but when they're serialized, I can't compare them to another entity. Is there another way I can assign these three roles to CreatePlayersWithRoles so that they're all assigned to a different entity attribute?

Attached is the updated OML file.

GreatestIdeaMafia.oml
2023-11-22 10-51-50
Jozy Sohail

hi @joseph, 

are there any other attributes in the main list other then name and roles?

if possible can you share the OML?

Regards,

Jozy.

UserImage.jpg
Joseph Kuhn

It's just name, and a list of roles.

OML is attached. Thank you!

GreatestIdeaMafia.oml
2021-06-21 12-37-59
Wei Zhu
Solution

This is expected behaviour.
It seems you are confused with Current property of List.

Usually we use Current  in For Loop to get / assign value of current element of the List.
If we use Current without For Loop, then it is the First element of List.
If  it is an empty List, then Current is just an empty element.

About your issue, even you assign value to Current.Play, List itself are still empty List.
So you need 
1. Define an PlayerWithThreeRoles Type Variable Element
2. Assign value to Player of Element
3. Add Role to Element
4. Append Element to List.

 

Regards
Wei

UserImage.jpg
Joseph Kuhn

Thank you! This fixed it and is returning what I wanted.

Following this, I have one more question. As you might have seen in the OML, I'm passing the Role Identifier in the Roles list, which is why it's returning three "1"s. I'm storing these values in an entity, but I'm currently serializing the three values because I can't figure out how to input them to the CreatePlayersWithRoles action in RandomizeRolesOnClick. I would like to create an aggregate with these roles, but when they're serialized, I can't compare them to another entity. Is there another way I can assign these three roles to CreatePlayersWithRoles so that they're all assigned to a different entity attribute?

Attached is the updated OML file.

GreatestIdeaMafia.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.