cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CBO29
Frequent Visitor

Another situation where a button need to be hit twice to get 2 instructions executed

Hi,

I have a button intended to reset a combo box selection in a 2-step fashion:

1. It resets the selection

2. It re-initializes a collection created following an OnChange on the combo box (which I needed to allow a many-to-many selection, see Many on Many Filter - Power Platform Community (microsoft.com) very useful)

 

Namely, the onSelect of the button goes as:

Reset(comboMZ); // 
ClearCollect(colComboSelection, originalSharepointList);

 

That works fine, but requires to press the button twice.. so really that doesn't work fine.

Any suggestion as how I could circumvent that?

Thanks in advance

CBO

1 ACCEPTED SOLUTION

Accepted Solutions
v-yujincui-msft
Community Support
Community Support

Hi @CBO29 ,

 

The problem seems to be that the Reset() function triggers the OnChange property of the ComBo Box Control.
Maybe you could consider setting a variable.

I have made a test for your reference.

 

1. Add a Combo Box Control and apply the following formula on its OnChange property as:

If(var=1, ClearCollect(colComboSelection, "A","B","C"),ClearCollect(colComboSelection, ComboBox1.SelectedItems));Set(var,0)

2. Add a Button Control and apply the following formula on its OnSelect property as:

Reset(ComboBox1);Set(var,1)

 

Result:

Result.gif

 

Best Regards,

Charlie Choi

View solution in original post

2 REPLIES 2
v-yujincui-msft
Community Support
Community Support

Hi @CBO29 ,

 

The problem seems to be that the Reset() function triggers the OnChange property of the ComBo Box Control.
Maybe you could consider setting a variable.

I have made a test for your reference.

 

1. Add a Combo Box Control and apply the following formula on its OnChange property as:

If(var=1, ClearCollect(colComboSelection, "A","B","C"),ClearCollect(colComboSelection, ComboBox1.SelectedItems));Set(var,0)

2. Add a Button Control and apply the following formula on its OnSelect property as:

Reset(ComboBox1);Set(var,1)

 

Result:

Result.gif

 

Best Regards,

Charlie Choi

Hi Charlie,

Sorry for the late answer as these are things I do on the side... But brilliant, this works perfectly and was the type of workaround I was looking for.

Many thanks

CBO

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,836)