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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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