Hi, i found a bug in Outsystems
1. in the program there is a variable local of type List
2. The list elements are then populated.... using equation like
List.,,,,.current.attr = 'bugs'
...
3. then the List is passed to other action, say it action B
4. In the B, the element's value exists ('bugs'..etc)
5. What amazing is that the property Empty of the List is still TRUE
To workaround, use appendList and create another local variable of the element's type.
may this helps, thanks
can you give more details, like what type of application, what type of actions (server ? client ? screen ?)
EDIT : Ok, just did a quick test, and can see same thing, I think i would expect it to still be empty, but it is confusing that it has value.
ALSO : it has nothing to do with passing to other action, anytime you assign an element value of an empty list, the list is still empty.
Yes, it will be a logic error as in the Action B there is a check like this
if Data_Pallete.Empty ...blabla...
It is a server action called another server action
thanks
I don't think this is a bug. If you don't append anything to an empty list, I think it makes sense for "Empty" to be True. If you're going to use the list in some logic, either to assign values to it or to read its values, you should always start with checking the Empty property.
yes, agree the Empty being True is correct, but it is confusing that you can assign to list.current, and also retrieve value out of list.current, all while it being empty.
For most uses of a list, like iterations, or a table widget, that won't be a problem though, it will simply act like an empty list, even if there are values filled.
So, as you say, it comes down to coding hygiene of checking against empty before doing something with current.
Hi, i think the spirit of OS is to enable citizen developer to do programming safely.
If the list element can be assigned, but it is considered empty, it is not a good reasoning, prone to logic error.
Correct, but this is only one of multiple examples where you can make not working code that OutSystems doesn't detect. Another example is using an expression with = on the right part of the Assign widget. OutSystems will not detect this as an error, typical beginner mistakes. You can even make action flows that are syntaxwise not correct that OutSystems will not detect. These things you see also in other programming languages, syntax wise they are correct, but the result of what you code is wrong because you do something that wasn't intended.
For example this is not detected as an issue, but makes not sense either:
Or an action flow with just this, is also not detected as an issue.
Hi ibox,
I don't think this is a bug, as if you use a local variable (list type) then 'assign' it other list type local variable, whatever happens in first variable will also applied to second variable.
To achieve another result (only get all records at that moment only) use 'List append all' to another variable. This approach will send all records to other variable at current state, and will not change eventhough the first variable changed.
Hi Sir,
here is the osp and a snapshot of my use case:
thanks and regards
OS - middle way: "Space cannot be empty, but can be checked empty" ..JK
Ok, there seems to be a lot of confusion here, and I agree that on the surface it looks weird, and yes, the documentation should probably be a bit clearer on this point. However, this is what it is:
This is not a bug, and it has always been the case (15+ years). It's just one of these things you need to remember when working with OutSystems. Also, one very, very important addition to the above:
Also, be aware that there are only five cases when Current is guaranteed to point to a specific, predictable record:
In all other cases, do not rely on Current pointing to a specific element, as it is not guaranteed to be predictable. This is particularly true after using a List action (ListAppend, ListInsert, ListIndexOf etc.), do not write code that depends on Current being a specific record (even if, e.g., after a ListInsert it seems to always be the record inserted, etc.), as it is not guaranteed to always be the case.
Thanks Sir,
The statement that a list always has a Current variable reminds me to a dummy node in a linked list, and it makes the algorithm much easier to write for all the linked list's operations (insert first, middle, last, delete, etc) .
Regards