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

Variable not set correct on start

I have a problem with showing and hiding icons. 

 

I have a variable called EditRep. I have three icons i'm setting different visabilities and type of icon. 

 

I have an Edit icon that has an OnSelect value of

 

UpdateContext({EditRep: !EditRep})

On the type of Icon I have the following

If(EditRep, Icon.Cancel, Icon.Edit)

I have a delete icon with the visibility set to 

EditRep

I have a save icon with the visiblity set to 

DeleteIco.Visible

My issue is when the powerapps page loads, both delete and save show and the edit/cancel icon is set to edit. It's like EditRep is set to true for the save and delete but false for the edit/cancel icon. 

 

I do have a couple other UpdateContext in the form to set the values back to false, but those are on the delete OnSelect and Save OnSelect. Should I change those to !EditRep instead of false?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Variable not set correct on start

Hi @dmowry 

 

created same scenario as you described and it works

 

Is there any other place where you are modifying the context variable

 

Try doing this OnVisible of your screen

UpdateContext({EditRep: false})

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Highlighted
Dual Super User II
Dual Super User II

Re: Variable not set correct on start

This is usually an issue with timing.  I've solved it in the past by using global variables and setting them in a Splash screen rather than ONStart.  That usually makes sure they are set before the first regular screen loads.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Helper I
Helper I

Re: Variable not set correct on start

Is there a way to have a splash screen act as a loading screen? Meaning, as the app loads, it shows a spinner, after the app is load then it sets the variable? 

 

Just not sure how to set the global variable so that it's false after everything has loaded?

Highlighted
Dual Super User II
Dual Super User II

Re: Variable not set correct on start

The point is to set the variables the way they should be for the initial load of the app while the splash screen is displayed.  Once that is done then show the first screen, which will now reflect the initial value of the variable.  And yes, you can display a spinner on the Splash screen.  But Splash screens are normally loaded based on a timer.  I'm not sure how you would determine that the app was loaded so you could dismiss the Splash screen.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Dual Super User
Dual Super User

Re: Variable not set correct on start

Hi @dmowry 

 

created same scenario as you described and it works

 

Is there any other place where you are modifying the context variable

 

Try doing this OnVisible of your screen

UpdateContext({EditRep: false})

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Highlighted
Helper I
Helper I

Re: Variable not set correct on start

That worked. Thank you

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,846)