What data will be hold by list.current when list is empty?? 

Hi Sana,

You will be able to access it but everything will be empty. The simple data types will be empty and the records will have all the variables inside it empty.

Hope this helps.

Regards,

Marcelo

Hi Eduardo,

Never said that current would be empty. I said the types inside would be empty. But yes you are right empty is not the correct wording. As you said the types will have their default values would be a better answer.

Regards,

Marcelo

thank you for your answers... 

I am confused with the two options... 

Does this list.Current will points empty record of entity or a null value.. ?

 If the list is not a userlist...its just an empty list will no values.. 

Hi Sana,

list.current will contain a record of the entity of that list with all the fields with their default values.

In this link you can check the default types https://success.outsystems.com/Documentation/10/Reference/Data/Data_Types/Available_Data_Types

Regards,

Marcelo

Hi Sana,

List.Current will hold the default values of the variables, when list is empty.

What Eduardo said is not correct. When not in a loop, the current is a direct reference to the first element in the list. 

"Changing the Current values will have absolute no impact in the list"  is the furthest thing from the truth, and is not true.

Changing the current WILL effect the list. Never use the current to add elements to a list. Always create a separate record. 

Hi Shawn,

How are you?

Yes, you are correct. 

When I gave this answer I was thinking that the Current was a "variable per se", that is not true. It is a reference to one item of the list (or to a phantom item if the list is empty).

After that, I learned it better.

Thanks to pointing it out so that if someone stumbles upon this topic, may not get a piece of wrong information. :)


Cheers!

P.S. I can't edit to point that this information was wrong, so I'll just delete it so no one else will assume the same incorrect information.

Solution

Here the same answer I gave before, now with the wrong information fixed:

Hi Sana and Marcelo,

May I improve and perhaps make a small correction to the given answer?

The Current of a list is a variable whose type is the same type of the list itself.
By itself, it does not depend on the list content.

Changing the Current values will have absolutely no impact on the list while changing the list directly (through the [ ] operator will also make no changes in the Current variable.

The Current is initialized when an aggregate / sql is executed, when you click an item in a Table Records or List Records in a screen or when you iterate a list using a ForEach.

In the first case, after the list is filled the first item in the list is copied to the Current (EDIT) points to this element.
In the second case, (EDIT) the current points to the clicked row item is copied to the Current.
In the third case, from start to end, (EDIT) the Current points to the actual row is copied to the Current in each step of the loop.

But, what if the list is empty?

Like I said in the beginning, the Current is a variable of the same type of the List. If the list is empty, Current will hold the default values for the types. Like, if your list is User List (User entity record list), Current will be User Record, and the Id will hold value 0, Name will be an empty string "", IsActive will be False, etc. 

So, it is not correct to say the Current is "empty", I think, as the Current effectively exists and you can use it, and there are values in it (default values of the data type or user default values if defined).

Hope this helps.

Cheers. 


Solution

Eduardo Jauch wrote:

Hi Shawn,

How are you?

Yes, you are correct. 

When I gave this answer I was thinking that the Current was a "variable per se", that is not true. It is a reference to one item of the list (or to a phantom item if the list is empty).

After that, I learned it better.

Thanks to pointing it out so that if someone stumbles upon this topic, may not get a piece of wrong information. :)


Cheers!


Hey I'm good.

I stumbled upon it and got the wrong idea about the current. But after getting wrong results realised eventually how it is working. Thanks for fixing it up. Regards.

SHould be me to thank you, for finding it and give me the opportunity to fix it. :)
Cheers and happy weekend! :D

Eduardo Jauch wrote:

SHould be me to thank you, for finding it and give me the opportunity to fix it. :)
Cheers and happy weekend! :D

Thank you Eduardo. Likewise.

And sorry if I came across a bit harsh, I was a bit frustrated cause it caused some bugs in my code.


Don't worry, I totally understand and the fault was mine.
I was just trying to cool down things a little and fix my mistake. :)