Re : Problems retriving selection from List Box widget

Hello all,

I am having trouble retriving selection from the List Box widget.
What I want is to store the selection on the OnChange notification of the List Box.
But when I check the List Runtime Property, that should contain the selection, during the OnChange flow, it is empty. It seems the List property is not  being updated.
What am I doing wrong? Can anyone help?

Thanks in advance.
Hi Pedro,
 
Take a look at these post:
 
https://www.outsystems.com/NetworkForums/ViewTopic.aspx?Topic=Listbox-selection-values
 
https://www.outsystems.com/NetworkForums/ViewTopic.aspx?Topic=List-Box-doesn't-set-Selection-Attribute
 
If in none of these posts you find the solution for your problem, please share your eSpace or a sample eSpace where this situation happen for us see what is going wrong.
 
Regards,
Nelson Baptista
Hello Nelson,

First of all, thanks a lot for your help.
Sadly, the links you provided weren't the solution to my problem.

I will explain:
I have 2 list boxes, were the contents of the 2nd LB depend on the selection of the 1st one.
I can get the selection of the 1st LB without any problem.
Despite the fact that the 2nd LB shows the data correctly, I cannot get the selected item. The list property is always empty.

Attached is a sample eSpace with this problem.
Thanks in advance.
Hi Pedro,
 
In attachment is the eSpace with a little change. In the screen action OnTable1Selected, I assigned the result of the query to a local variable and this variable is the source record list of the lisbox2.
 
Regards,
Nelson Baptista
Hi Nelson,

Thanks a lot!!!
Your solution works like a charm.

Best regards

I am glad I found this post, but a little frustrated that it took several searches and a couple of hours of trial and error along with research to finally uncover it. I would strongly recommend that you put a note in the core documentation of List Box widgets that the only way to make them work as expected is to use a local variable in between the aggregate and the list box. And include a link to the documentation for how to make a hybrid local variable that includes an entity along with a single new field (the Boolean value for the selection attribute).

The links from Nelson Baptista are no longer active... And I need help using the listbox with multiple selection...

I am using the following local variable to store the options for the listbox:

And I'm using it like this:


But it does not change the boolean value to true, when I have my options selected... What am I doing wrong?

Hi Clara,

The Source Record List is only used *to initialise* the Listbox's internal List runtime property (in your case accessible via ComboMultiplosAgentes.List).

My guess is you are checking the UserAgente contents instead of the ComboMultiplosAgentes.List.

I was able to detect the selected item by binding to a local variable as suggested. However, if you reload your list data inside of an AJAX submit (and update your local variable and call an Ajax Refresh on the listbox) then you can no longer detect the selected item. The boolean value is never set to true when iterating through the MyListBox.List list and I know the loop is correct because it works as expected before it is reloaded inside of an AJAX submit. 

In my case I have a button on the page that inserts a new record then reloads the list box. The list box reloads as expected and the new record is in the list but you can't detect the selected item afterwards. 

Hi Roy,

if you Ajax Refresh your MyListBox, it's List property will be reinitialized with the data fetched from the Source Record List, so any selections will be lost, unless you also store them in the database, or somehow keep track of them on your screen action logic.