cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Update context based on Listbox Select

Hello,

 

Can I update a contex variable based on a value selected in a listbox?  I am having a little trouble since the I have formatted the items in the list box.

 

Thanks for your help,

Scobie

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Update context based on Listbox Select

Hi @Scobie,

 

As suggested by @Drrickryp, could you please share the solution that you have found?

 

Basically the Variable could be updated with two function:

UpdateContext()

and 

set()

for Galbal variable

 

For ListBox control, we could get its value by ListBox.Selected, and for specific field, it should be: ListBox.Selected.FieldName

 

and if Multiple selection has enabled, the value then is stored in 

ListBox.SelectedItems

 

So to change Variable value with the ListBox selected value, the formula should be:

UpdateContext({VariableName:ListBox1.Selected})

or

UpdateContext({VariableName:ListBox1.Selected.FieldName})

for the Set() function, it should be:

Set(VariableName, ListBox1.Selected)

Or

Set(VariableName, ListBox1.Selected.FieldName)

For Multiple items, switch the ListBox1.Selected to ListBox1.SelectedItems.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Advocate II
Advocate II

Re: Update context based on Listbox Select

I was able to solve the problem I was having. Can anyone tell me how I can delete this post.

Highlighted
Super User
Super User

Re: Update context based on Listbox Select

 
Highlighted
Super User
Super User

Re: Update context based on Listbox Select

Could you share your solution with us instead of deleting the post?
Highlighted
Community Support
Community Support

Re: Update context based on Listbox Select

Hi @Scobie,

 

As suggested by @Drrickryp, could you please share the solution that you have found?

 

Basically the Variable could be updated with two function:

UpdateContext()

and 

set()

for Galbal variable

 

For ListBox control, we could get its value by ListBox.Selected, and for specific field, it should be: ListBox.Selected.FieldName

 

and if Multiple selection has enabled, the value then is stored in 

ListBox.SelectedItems

 

So to change Variable value with the ListBox selected value, the formula should be:

UpdateContext({VariableName:ListBox1.Selected})

or

UpdateContext({VariableName:ListBox1.Selected.FieldName})

for the Set() function, it should be:

Set(VariableName, ListBox1.Selected)

Or

Set(VariableName, ListBox1.Selected.FieldName)

For Multiple items, switch the ListBox1.Selected to ListBox1.SelectedItems.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate II
Advocate II

Re: Update context based on Listbox Select

Hello @v-micsh-msft,

 

Yes I was able to use:

UpdateContext({VariableName:ListBox1.Selected.FieldName})

 

But I was having trouble getting that to work with how the ListBox sets up its items from the help I got from dinusc in this question I asked:

https://powerusers.microsoft.com/t5/General-Discussion/Formatting-a-Listbox/m-p/147763/highlight/tru...

 

At first having the .singleColumn at the end of the items property gave me problems. But by changing it around abit I got it to work. 

 

It is a little hard to explain so I thought it would be easier to delete the post.

 

Hopefully that helps, 

Scobie

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,708)