Initializing a list

Initializing a list

  

I need to initialize/assign a userList variable as shown below,



How can I do it in outsystems?

Hi Neha,

It depends on where and when you want to use it. If you only need it in the scope of a screen, you can create a local variable. Set the Data Type to List, and select '"text" thereafter (assuming you want a list of strings). In the preparation / screen action, you can append items to the list with the server action 'List Append'. You may also create a sctructure, and use that to append the list items to.

Kind regards,
Sam

Solution

Hi Neha,

If the list is of type string, which you want to have two strings "User1" and "User2", you can do it like this:

This is using the server Action ListAppend

For Mobile Apps you can do it in a simular way client side using the client action ListAppend.

Regards,

Daniel

Solution

Hi Neha,

Though the answers have been given above, I want to stress the importance of taking the online courses. List handling (and creating) is very basic stuff, which makes me believe you didn't take the beginners courses. Please make sure you have taken them, so you are better prepared to be an OutSystems developer. Happy coding!

Daniël Kuhlmann wrote:

Hi Neha,

If the list is of type string, which you want to have two strings "User1" and "User2", you can do it like this:

This is using the server Action ListAppend

For Mobile Apps you can do it in a simular way client side using the client action ListAppend.

Regards,

Daniel


Here the type of the list is generic what if I have a type wherein UserList actually holds (Id, Name, ContactNo) How do I assign values in that case?


Hi Neha,


 If i understand correctly you want to have a list with each element containing several fields, then you have to create a structure that has those 3 types (id is of type entityidentifier, Name is string, ContactNo is phonenumber).

 Then you create your variable in your screen, and you tell that variable to be of type list record of the type of the structure!

Hi Neha,

You completely ignored me, so I'm going to tell you again, that all this is very, very basic OutSystems stuff. Take the online courses please, to start with, and all of these things will be explained.

Kilian Hekhuis wrote:

Hi Neha,

You completely ignored me, so I'm going to tell you again, that all this is very, very basic OutSystems stuff. Take the online courses please, to start with, and all of these things will be explained.

Hey Kilian,

Sorry about that but I was in urgent need of solution and yes I will go through the basic sessions once again. I might have missed it in first go.


Thanks,

Neha

Hi Neha,

As per my understanding, i have create an example.i think this will help you.


Thanks

Jitendra