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

Reset Combo Box depending on items selected from drop down

In my form, which is in editmode, I have a dropdown (HubType2_Edit).  This lists 3 options:

 

Learning Hub - Facilitation

Learning Hub - PC Only

Future Talent

 

If future talent is selected, 2 options appear, a textbox asking to enter a room number and a combo box (HubSessions2_Edit) asking to select one or more future talent sessions.

 

What i would like to happen is if they change the booking and select either of the other 2 options, the combo box resets to have nothing selected.

 

I have tried on the OnChange of the dropdown -

 

If(HubType2_Edit.Selected.Value = "Learning Hub - Facilitation" || HubType2_Edit.Selected.Value = "Learning Hub -PC Only", Reset(HubSessions2_Edit)) 

 

This didn't work.

 

I also tried on the defaultselecteditems property of the combo box:

 

If(HubType2_Edit.Selected.Value = "Future Talent",ThisItem.Sessions, Blank())

 

That didn't work either.

 

Does anyone have any ideas what i am doing wrong or suggest a way to fix this?

 

thanks

Alistair

10 REPLIES 10
Highlighted
Microsoft
Microsoft

Re: Reset Combo Box depending on items selected from drop down

Hello @neill_long,

You are very close! In order to reset the ComboBox control, you will actually have to 2 both:

1. Rerset the DefaultSelectingItems to Blank() (or just to []) and

2. Use Reset(YourComboBoxControl) function.

THe best way would be to bind the DefaultSelectedItems property to a variable ("dd" in my example below) and then use the following formula to reset it: Set(dd, Blank());Reset(YourComboBoxControl)

Highlighted
Helper III
Helper III

Re: Reset Combo Box depending on items selected from drop down

Hi @dinusc

 

Thanks for your reply.  I'm not sure i am understanding, sorry.

 

I have now added this the OnChange of the DropDown property:

 

Set(Sessions, Blank()); Reset(HubSessions2_Edit)

 

Sessions being the column in the SPO list and HubSessions2_Edit being the combo box.

 

Can you help and guide me back in the right direction?

 

thanks

Highlighted
Microsoft
Microsoft

Re: Reset Combo Box depending on items selected from drop down

I'm sorry for confusion. Do you have anything set to your HubSessions2_Edit.DefaultSelectedItems property? If so then please assign it to a variable instead. For example: Let's say that you have 

HubSessions2_Edit.DefaultSelectedItems = Filter(SomeSource, Feild="SomeCriteria);

My suggestion was to change this to:

Screen1.OnVisible= Filter(SomeSource, Feild="SomeCriteria)

HubSessions2_Edit.DefaultSelectedItems = dd

After that, you should be able to reset your ComboBox control (HubSessions2_Edit) as following:

Set(dd, Blank()); Reset(HubSessions2_Edit)

According to your previous example, DropDown.OnChange should be:

If(HubType2_Edit.Selected.Value = "Learning Hub - Facilitation" || HubType2_Edit.Selected.Value = "Learning Hub -PC Only", Set(dd, Blank());Reset(HubSessions2_Edit)) 

 

Does this makes sense?

Highlighted
Helper III
Helper III

Re: Reset Combo Box depending on items selected from drop down

@dinusc

I think i am slowly getting there.  What i have now is as follows:

 

I had on the DefaultSelectedItems property: ThisItem.Sessions 

 

Screen OnVisible:

 

Filter(NEWLDRLearningHub,Sessions = "Sessions")

 

Sessions Combo Box (HubSessions2_Edit) defaultselecteditems

 

dd

 

Dropdown (HubType2_Edit) On Change:

 

If(HubType2_Edit.Selected.Value = "Learning Hub - Facilitation" || HubType2_Edit.Selected.Value = "Learning Hub - PC Only", Set(dd, Blank());Reset(HubSessions2_Edit))

 

Now what's happening is when i navigate to the screen, the combo box is empty and not displaying the chosen sessions options for that record.

 

If they users had originally selected Future Talent, the sessions should be on display and should only reset if anything other than Future Talent is selected from the dropdown options. 

 

Sorry about this, i'm still fairly new to this and still trying to understand but if you can advise anymore that would be great.

 

thanks

Highlighted
Microsoft
Microsoft

Re: Reset Combo Box depending on items selected from drop down

Thank you for providing more information. The Screen.OnVisible formula seems wrong. If I understand correctly, the ComboBox initially should show selected sessions? If so then what should happen on Screen Visible event is the "dd" variable needs to be set with filtered sessions. Please change your existing formula: 

Screen.OnVisible=Filter(NEWLDRLearningHub,Sessions = "Sessions")

with

Screen.OnVisible=Set(dd,Filter(NEWLDRLearningHub,Sessions = "Sessions"))

 

 

Highlighted
Helper III
Helper III

Re: Reset Combo Box depending on items selected from drop down

@dinusc

I have added to On Visible of Screen1:

 

Set(dd,Filter(NEWLDRLearningHub,Sessions = "Sessions"))

 

On the defaultselecteditems, i have put: dd

 

On Change of DropDown:

 

If(HubType2_Edit.Selected.Value = "Learning Hub - Facilitation" || HubType2_Edit.Selected.Value = "Learning Hub - PC Only", Set(dd, Blank());Reset(HubSessions2_Edit))

 

Still not showing the items in the combo box.  Are you able to see what i might be doing wrong?

 

If not i think i will leave this for now.

 

thanks

Highlighted
Microsoft
Microsoft

Re: Reset Combo Box depending on items selected from drop down

When you say that you don't see items in the ComboBox, do you mean the items in the dropdown list or in the "selected" area? 

Highlighted
Helper III
Helper III

Re: Reset Combo Box depending on items selected from drop down

I see the items that can be selected.  But it doesn't show the 'selected' ones 

Highlighted
Microsoft
Microsoft

Re: Reset Combo Box depending on items selected from drop down

Since you're already setting the "dd" variable to your ComboBox.DefaultSelectedItems and populating it on Screen.OnVisible, the only reason I can think of the items do not appear selected is if your Filter formula does not return any results. Can you add a test Gallery control temporarily and set its "Items" property to:

Filter(NEWLDRLearningHub,Sessions = "Sessions")

Make sure you see those items in your test gallery control. 

Another reason could be that you're not changing the screens and therefore the formula from Screen.OnVisible does not run. Try to add a new screen, switch to it and then switch back to your screen to ensure the OnVisible formula is triggered.

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 (10,029)