cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Set variable to item selected in List Box

Can understand why this doesn't work.  

 

I have a list box named "Players".   I select one of the players from the list and click button "1", which should set the player's name as Variable1 so I can put it in a specific text box.   The formula I used for button 1 to create the variable was:

OnSelect = set(Variable1, Players.SelectedItems)

 

I didn't get an error message with that formula but when I set my text box to:

Text = Variable1

I get the error message:  The property expects text values, but this rule produces incompatible Table values.

 

I don't get it.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: Set variable to item selected in List Box

Hello,

It's difficult to know why you have this error. And I don't know what to ask in order to help myself understand.
Maybe you Set the same global variable somewhere else as a different type.

Just create a new app and test it, to see how it works. If you understand it, then you may debug your issue.

View solution in original post

14 REPLIES 14
Highlighted
Super User III
Super User III

Re: Set variable to item selected in List Box

Hi @hughrmarks

 

Users can select multiple items from a list box. Therefore, Players.SelectedItems returns a table that contains all the selected items from the list box. This explains the error message that you see.

 

If you want to show just the first selected item in your text box, you can use formula that looks like this:

 

First(Variable1).Value
Highlighted
Helper IV
Helper IV

Re: Set variable to item selected in List Box

Well the text box error message is gone but now there's an error on the button:

Expected: "Ident"  Found: "Control"

 

 

Highlighted
Super User III
Super User III

Re: Set variable to item selected in List Box

When you click the error icon, what property does the designer highlight that 'expects an ident, but finds a control'?

Highlighted
Helper IV
Helper IV

Re: Set variable to item selected in List Box

The button.

 

It's the one that onSelect attemps to create the variable:

Set(Variable1, Players.SelectedItems)

Highlighted
Super User III
Super User III

Re: Set variable to item selected in List Box

Yes, but which property of the button? The designer should highlight the formula that contains the error - which property of the button is associated with the formula that causes the error?

Highlighted
Helper IV
Helper IV

Re: Set variable to item selected in List Box

"Players" is highlighted when I click the error icon.

Highlighted
Solution Sage
Solution Sage

Re: Set variable to item selected in List Box

Hello hughrmarks,

You can set the property of the button1 like this:
Button1.OnSelect = set(Variable1, Players.Selected.Value)

Just to see how is works, create a new label next to your listbox and set the property
NewLabel.Text= Players.Selected.Value

The last selection of the ListBox will be displayed as text in the label.

Highlighted
Helper IV
Helper IV

Re: Set variable to item selected in List Box

When I do that, I get this error message on the button:

Expected: "Ident"  Found: "Control"

 

And I get this error message on the text box:

Invalid use of "."

 

 

Highlighted
Solution Sage
Solution Sage

Re: Set variable to item selected in List Box

Hello,

It's difficult to know why you have this error. And I don't know what to ask in order to help myself understand.
Maybe you Set the same global variable somewhere else as a different type.

Just create a new app and test it, to see how it works. If you understand it, then you may debug your issue.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (4,143)