cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper 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
Helper II
Helper 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
Helper II
Helper 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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

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

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,055)