Tip: issues using ListAppend: first record duplicate of last; first record missing

When manipulating record lists using ListAppend, you may find that you are having one of two problems:
- In lists of 2 records, you see that the first record of the list is missing; Instead, you have 2 copies of the last record.
- In list of more than 2 records, you see that the first record is missing. Instead, the last record of the list is copied to the first record.


TLDR You are using the “List.Current” record to add records to your list as a shortcut and that shortcut has that behavior. Fix your app by creating a temporary record that you use to make all the insertions.
Longer explanation
This problem happens when you want to copy records from a list to another list, where the original record is one of the fields. In these patterns, it is tempting to use the “Current” record of the target list as a shortcut - avoiding the need to create a variable used only for the append operation.

The reason this problem is possible (to begin with) is the fact that OutSystems cannot provide an “empty” list - meaning, a list where you would not be able to assign to its current record - another of the consequences of the strongly-typed nature of OutSystems.

This means that, in practical terms:
- An empty list has 0 records (length is 0) but you can still assign to List.Current still (the “current record” of the said list).
- If you don’t explicitly add the record to the list, the list will still be empty, BUT List.Current still shows you the values you have.
- From the moment the list has a record, List.Current still will point to a valid record of the list. If you assign to it, you are altering the list.
I created a simple application in my Personal Environment that shows how this happens. I attached it to this post as well so you can look at what’s being done.


After you’ve read the cause, you’ll find that the problem is wrong use of List.Current in your application. To fix it, stop using List.Current to fill in the record list; instead do it by creating a temporary record that you use to make all the insertions..
Hope this helps!

Thank you for this, have been troubleshooting for awhile and couldnt't find the cause. 

Thank you This was very helpful

??????? sbobet


I'm going round in circles, and I still find this error.

I have a dropdown with a Source Record List being a SOAP Service list.

I want to take the element stored in the dropdown (This is List.Current) and Add it to a Table.

I then want the element which I have been added to be removed from the dropdown List.

I also want an option to remove Items from the Table which puts that element back in the dropdown.

I'm a bit in a muddle with what variables are lists, what are records and what goes where.

Can anyone help?