cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaWu
Level 8

Problems with ComboBox.OnChange triggering too often and with weird timing.

Hello

Please be so kind as to read my full post before responding.
Thank you for your consideration.

In my PowerApp I often use the pattern of having something like

UpdateContext({
    unsaved: true
})

in my input controls, and only show things like Save or Reset buttons depending on unsaved.
In my MyForm.OnReset event I have

UpdateContext({
    unsaved: false
})

and my Save and Cancel buttons both use

ResetForm(MyForm)


However, I am having trouble using this together with ComboBoxes used with LookUp fields when using Save, or when entering the Screen.
It appears that the ComboBox.OnChange event gets triggered with a "weird timing" and more often than, say, TextInput.OnChange.
Hence, whenever I enter the screen or Save anything (Save triggers ResetForm in my case), ComboBox.OnChange gets triggered.
In contrast, for example TextInput.OnChange only gets triggered with an actual text change.

As an example to better highlight my problem, I have slightly modified one of my PowerApps that uses ComboBoxes in an EditForm.
I added a text context Variable logTxt with Screen.OnVisible

UpdateContext({
    logTxt: ""
})

and changed ComboBox.OnChange to, and note the "safeguard" resetting

UpdateContext({
    logTxt: logTxt & "
ComboBox.OnChange"});
If(!resetting,
    UpdateContext({deliveryUnsaved: true})
)

all my TextInput.OnChange to

UpdateContext({
    deliveryUnsaved: true,
    logTxt: logTxt & "
TextInput.OnChange"
});

and Form.OnReset

UpdateContext({
    deliveryUnsaved: false,
    logTxt: logTxt & "
Form.OnReset"
})

I also added a big Label with Label.Text set

"logTxt:
" & logTxt

and at the end of my Cancel/ResetForm and my Save buttons I have

UpdateContext({
    resetting: true
});
ResetForm(LieferungForm);
UpdateContext({
    resetting: false
})



Using, this, upon entry to the screen, with nonempty default record selected, I already see this:
image.png

That is, by "virtue" of ComboBox.OnChange triggering, I have already entered my PowerApp Mode of having unsaved changes without actually having done anything.

Changing the Text in one TextInput yields:
image.png

Saving via SaveButton.OnSelect and thus triggering ResetForm yields:
image.png

which causes an unexpected triggering on ComboBox.OnChange after Form.OnReset ignoring the resetting safeguard and the order of functions inside my SaveButton.OnSelect event.

Trying to afterwards change the ComboBox itself triggers another ComboBox.OnChange:
image.png

Saving and triggering ResetForm again yields:
image.png

which again causes an unexpected triggering of ComboBox.OnChange after Form.OnReset ignoring the resetting safeguard and the order of functions inside my Save buttons OnSelect event.

 

My questions:

  1. How do I get this setup to work even with that ComboBox.OnChange nonsense?
  2. Why is ComboBox.OnChange triggering so often, and completely inconsistent with the way OnChange gets triggered for TextInput controls?
  3. Why is ComboBox.OnChange triggering at all from using ResetForm? No other controls seem to do this.
  4. Shouldn't Form.OnReset trigger after all controls inside the form have already been reset, i.e. shouldn't Form.OnReset be in my logs after ComboBox.OnChange?

Last tested with:

App ID: 8200a3f3-30fd-44f9-b3b7-0c9e0f803c50
Session ID: 21a66c2e-a2f6-472c-bffc-a84600ce0745
PowerApps 3.19081.26


If you have read all of this properly, thank you!
If you have a solution for me or know documented answers, thank you and kudos!
    Sa.

1 ACCEPTED SOLUTION

Accepted Solutions
Rebetcha
Level 10

Re: Problems with ComboBox.OnChange triggering too often and with weird timing.

Hi @SaWu ,

Apparently the Combo Box logic of OnChange is simply different than for the rest of the controls. I would post this as an idea to bring it under the attention of the Product Team. 

Regarding a work around: instead of using a variable you can do the Excel thing and compare the current value of the combo box to the ThisItem.Value of the corresponding field directly in the Visible property of for example the Save button. 

View solution in original post

3 REPLIES 3
Rebetcha
Level 10

Re: Problems with ComboBox.OnChange triggering too often and with weird timing.

Hi @SaWu ,

Apparently the Combo Box logic of OnChange is simply different than for the rest of the controls. I would post this as an idea to bring it under the attention of the Product Team. 

Regarding a work around: instead of using a variable you can do the Excel thing and compare the current value of the combo box to the ThisItem.Value of the corresponding field directly in the Visible property of for example the Save button. 

View solution in original post

Highlighted
SaWu
Level 8

Re: Problems with ComboBox.OnChange triggering too often and with weird timing.

Hello @Rebetcha 

I have now posted this as an idea
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Please-make-ComboBox-OnChange-trigger-consistent...
And kudos for the workaround idea.

Thank you,
    Sa.

Rebetcha
Level 10

Re: Problems with ComboBox.OnChange triggering too often and with weird timing.

I voted up your idea! 🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 313 members 5,825 guests
Please welcome our newest community members: