cancel
Showing results for 
Search instead for 
Did you mean: 

Listbox - Pre-Selection of Listbox from Existing records

I can select multiple items on a Listbox. I wish to then save this selection with the possibility of have my selection recorded.

i can use Concat to turn my Selections in the Listbox to Comma Delimited text  so i can then save it to a DB or Sharepoint list. Listbox Update will not let me save the list without converting it to text anyway.

 

upon opening the record to edit it , Default will not allow Tables and  obviously there is no match for my comma delimited text .. i will only allow one item to be pre-selected.

 

Can i retrieve data and Pre-Select the Selected Items in a listbox when i open the record to edit? please

 

thanks


Seán

 

 

Status: Under Review
Comments
Level 10

Just to clarify the proposed idea.  It is simply to allow for the Defaults property of a Listbox to contain a table or a list so that multiple items can be preselected by default in a list box.

Microsoft Employee
Yes! I've been trying to work around this, but it's not possible to directly assign to `SelectedItems` so we're completely reliant on `Default`
Flow Staff

Yes, this is possible. Please try this:

 

Create a list box and call it ListBox1 (SelectMultiple=true) and bind it to your data. Then set the OnSelect property to:

UpdateContext({Found:Find(ListBox1.Selected.Value,ConcacenatedText,1)});If(Found<1, UpdateContext({ConcacenatedText:ConcacenatedText & "; " & ListBox1.Selected.Value}))

 

Create a TextBox and call it TxtConcacenated, Then set the Text property of it to:

ConcacenatedText

 

You may also need a reset button, the OnSelect of the reset button should be:

UpdateContext({ConcacenatedText:""})

 

Please let me know if this works for you. We really appreciate your feedback and ideas!

 

Thank you,

Audrie

Flow Staff
Status changed to: Need Info

Did my suggestion below help?

Audrie

Level: Powered On

Hi Audrey

Your code only takes selected items and populates a text field so i can save to a sharepoint list.

I am actually using Concat to do this in the update for the field. ( My listbox is custom as i want it to work smoothly and not to preload sharepoint list data.) e.g. Concat(Listbox1.SelectedItems.Value,Value & ",")

I am looking to prepopulate the selected Items when i go to edit the records at a later date. Is it possible?

 

e.g.

Listbox1 value A,B, C,D

I select A and C

I save A,C to Sharepoint text box.

I goto edit this record a few days later.

I want A and C to be preselected in the Listbox1

 

I hope i am clear.

Is it possible to in someway select an item or two on a listbox on a form?

 

Sean

 

Flow Staff
Status changed to: Completed

Ok, I understand now. It's not how to get the data into the list, it's how can you get it BACK into the ListBox after the data has been saved to SharePoint for edits later on. Smiley Happy

 

In order to do that you will have to parse and load the values from the Sharepoint field into a Collection at the appropriate time (perhaps as part of the OnVisible property of that form control, or only when the form is in Edit mode). Then you'll be able to set the ListBox items to that Collection.

 

Please give that a try. If follow-up is needed on this question, could you please post the follow-up question in the forum here, rather than the Ideas Forum. We usually respond to all questions from there much more quickly, as they do not require triage:

https://powerusers.microsoft.com/t5/PowerApps-Forum/bd-p/PowerAppsForum1

 

Thank you very much for continued ideas and feedback,

 

Audrie

 

 

Level: Powered On

Hi Audrie

 

I am not sure whether this is an Idea under consideration or not as the status says completed but still can't seem to find a way to implement this solution. 

 

pls can you suggest whether is it possible to set the default multiple selected items in to the listbox or not

 

Thanks

 

Flow Staff
Status changed to: Under Review
 
Level: Powered On

I have given up on listbox. It is Funny that edit a multi-select on a listbox was not considered important.

SO 

I have decided to use the Gallery as a list box.

1.

When someone gets to the edit sheet i have a jump to a new PeopleScreen Page with the gallery and also setting a global variable with the code. 

Set(V_PeopleListBox,ThisItem.People);Navigate(PeopleScreen,ScreenTransition.None)

 

2.

The data i had in a listbox was coming from a sharepoint list so when you create the Gallery just show the name as a label. 

An in the OnSelect I put

If (ThisItem.'{Name}' in V_PeopleListBox,Set(V_PeopleListBox,( Substitute(V_PeopleListBox, ThisItem.'{Name}' & ",",""))),Set(V_PeopleListBox,V_PeopleListBox& ThisItem.'{Name}'&","))

I need to comma delimit the selected data in case you were wondering as i am pparsing the data at a later stage.

3. To Highlight what i have selected I put this in a label beside my gallery box

If (ThisItem.'{Name}' in V_plantbox,RGBA(0, 0,255, 1),RGBA(0, 0,0, 0))

i didn't even look at checkboxes but that would be a better way possibly

 

4. When i am happy with my selection i close the peoplescreen

5. Make sure the Update for your sharepoint list note/text/memo field has the global variable.

Ta da!

 

 

Level: Powered On

i also need to set the global variable from the Detail screen as i go to editscreen.

Set(V_PeopleListBox,ThisItem.People)