cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HFG
Advocate III
Advocate III

Variables not working unless code is deleted and re-added

Hi all,

 

I'm building a canvas app and using global and local variables to show/hide some icons. I am having an issue that the icon is not showing even though the code is evaluating to true. If I delete the code and re-add it without changing anything the icon appears. Please see screenshots. 

 

Any ideas? 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
iAm_ManCat
Super User
Super User

Hi,

 

You are using a protected word (Edit, which is the DisplayMode.Edit protected property in the studio), in your formula, you will need to use another name for that variable as it is causing the studio to be confused about what you are referring to (which is why it sometimes evaluates to true, sometimes to false).

 

Also, you can see by the colour that both Edit and SpinnerData are not variables - is SpinnerData a control? If yes then please make sure you reference its property like !(SpinnerData.Value)

 

image.png

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

5 REPLIES 5
iAm_ManCat
Super User
Super User

Hi,

 

You are using a protected word (Edit, which is the DisplayMode.Edit protected property in the studio), in your formula, you will need to use another name for that variable as it is causing the studio to be confused about what you are referring to (which is why it sometimes evaluates to true, sometimes to false).

 

Also, you can see by the colour that both Edit and SpinnerData are not variables - is SpinnerData a control? If yes then please make sure you reference its property like !(SpinnerData.Value)

 

image.png

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi @iAm_ManCat 

 

Thanks for your reply.

 

The reason they are both blue is because they're context variables, the others are global variables.

 

As shown in the screenshots, in both cases the formula evaluated to true, however, the icon only showed up once I had deleted the code and readded it. 

Thanks for the info on the Edit word, I had wondered when I used it. I will change it to use a different word and see if that works.

 

 

HFG
Advocate III
Advocate III

HI @iAm_ManCat 

I modified the context variable to another word and now things seem to be working well. Thanks for your help.

Excellent, glad to hear its sorted - wish they had an explicit list of unusable words though, that would be super useful!

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


HFG
Advocate III
Advocate III

Agreed!

 

One thing I noticed is that when I went to view the variable, in the tab "Indirect Uses", a component which had no link to the context variable, but that used the formula If(Self.DisplayMode = DisplayMode.Edit), was in the list. This  confirmed to me that it was the use of Edit that was causing a problem. 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,275)