cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft ManishM
Microsoft

Updating variable using Set() does not work if executed from OnChange of a dropdown

This might be a bug. I am using web PA. I have a dropdown that executes commands for data collection based on value selected. When the process of gathering of data is happening, I would like user to see a msg like "Loading data. Please wait...". I used Set() to set variable to the msg as the first line and used Set() again to set the variable to "" (blank). However, setting variable lines were not executed.

 

However, I moved the first line to OnSelect of the dropdown, it executed the line the moment I clicked the control but there needed a line to reset the variable to "" (blank) after the process of gathering data was over which was still in the OnChange hence the msg was not set to blank.

 

Any workaround?

 

Thank

ManishM 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Updating variable using Set() does not work if executed from OnChange of a dropdown

Hi @ManishM,

 

I just tried the OnChange property of the Dropdown with the Set() command, it works from my testing.

 

Are you putting Set(Var, Value);Set(Var,"") together under the OnChange property of the Dropdown?

Doing this will Update Var with Value first, and then clear it in seconds.

 

The message here is "loading data", I assume there is a gallery or Data Table control within the current screen, right?

If yes, then we could workaround as below:

Set(Var, value);
if(!IsEmpty(Gallery.AllItems),
   Set(Var, ""))

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.
Microsoft ManishM
Microsoft

Re: Updating variable using Set() does not work if executed from OnChange of a dropdown

@v-micsh-msftThanks for testing it on your side.

 

To clarify further, between the 2 Set() commands, there is a ForAll loop which builds a Collection which takes about 15 seconds before it executes commands after it. Which makes it clear that the 2 Set() commands should not be executing one after the other, skipping the ForAll loop.

 

Fundamental question - shouldn't the code set execute in the order they are written? If that is so then this looks like a bug.

 

I also tried by moving the codeset to a button and then select the value from the dropdown and then pressing the button, it works; not an ideal way I would like the user interaction to be but it worked as expected. In the past I have never used OnChange() in a dropdown. I have used a loading... gif with circling dots, for such time consuming process and as a good practice to keep user informed, and set its visibility true as the first line of code and then false as the last line of code and it works beautifully. Even this did not work within OnChange in the dropdown.

 

Thanks

Manish

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,577)