cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LRVinNC
Level: Powered On

Same version (no changes) works when played - doesn't work when run in editor

I have a published app which works just fine. I went to make some enhancements and when I run it the first time in the editor, it did not produce the same results. I had made a couple of small changes, although they were in unrelated areas. To be sure they were not the problem, I restored a copy of the live version as my current version and then made no changes to try to get to the bottom of what is going on. Using that restored version, if I Run the app, my gallery works normally, displaying the expected information. If I Edit that same version and Run inside the editor, no data is being displayed in the galleryPlay.pngEdit.png

Idiscovered I am getting an error on a field was working fine when I last published the app.  I'm wondering if there was a change in a recent release that is suddening causing my problems.  

 

PlanYear is a global variable which is correctly set to 2019.  Planning Year, used to set the PlanYear global variable, is a Dropdown control on a screen where the default value is Year(Today()) or it can be set to another choice and saved.

PlanYear.pngDefinition.png

But this OnVisible Action on the Projects screen is telling me the PlanYear variable is invalid. 

Error.png

Here is the definition of the ProjectYear column on the Projects list as well.

 

Data.png

What am I missing here?

 

LRVinNC

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Same version (no changes) works when played - doesn't work when run in editor

Ahh, I see the problem. It looks like it's possible to set a variable to a dropdown control, but you can't reference the Variable.Selected.

 

As a best practice, when declaring a variable to a dropdown or combobox, I set it to:

Set(variable,Dropdown.Selected)

This drills into the dropdown one level deeper. Then you would reference the selected year as:

variable.Value

You would drop .Selected because you've already drilled into it.

13 REPLIES 13
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Same version (no changes) works when played - doesn't work when run in editor

Hi @LRVinNC,

Can you hover over the blue and red squiggly lines in the filter of your OnVisible property? Screenshot the error and shrae it here. That can provide clarification.

LRVinNC
Level: Powered On

Re: Same version (no changes) works when played - doesn't work when run in editor

@Mr-Dang-MSFT-- Brian, thanks for taking a look at this for me. 

 

Sorry, I should have been clearer when I said I was getting an error.  I'm getting the standard "Name Isn't Valid"... even though the name WAS perfectly valid when the app was previously published and I don't see anything wrong with the definition.  (The original blue squiggle is just a delegation warning which I am ignoring since there will never be enough records for this app to cause an issue).

Name not valid.png

 

You'll notice in my original post the definition of this global variable is Set(PlanYear, PlanningYear) -- with PlanningYear being a dropdown control on the Settings form.  Yesterday afternoon, I tried replacing PlanYear with PlanningYear in the action above and it accepts PlanningYear without generating an error.  But even though PlanYear should be a mirror of PlanningYear (based on the set statement above) it rejects PlanYear.  This definitely isn't the behavior I would expect, leading me to believe something had to change between the version enforce for the live version (Version 144 - Release 3.18112.22) and the version now being used in the editor (Version 146, clone of V144 - 3.19014.10).

Versions.png

 

Thanks, in advance, for any insights you might be able to provide.

LRVinNC

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Same version (no changes) works when played - doesn't work when run in editor

What's the columns of the PlanningYear dropdown look like? I'm thinking its column names have changed, causing .Selected.Value to no longer be valid.

Highlighted
LRVinNC
Level: Powered On

Re: Same version (no changes) works when played - doesn't work when run in editor

That's the thing, Brian, there were zero changes to the app between the live version and the version that failed.  I literally copied Version 144 back into a new version and hit run in the editor and it failed.  

 

But here's the info on PlanningYear.  

PlanningYear.png

 

And looking at PlanYear in seems to indicate that Selected. Value IS valid, doesn't it?  And it is clearly set with the value in PlanningYear correctly.

PlanYear.png

RandyHayes
Level 10

Re: Same version (no changes) works when played - doesn't work when run in editor

Setting a global variable to an Object seems to be the issue here.

Specifically in the case of the dropdown and other controls that have properties similiar to Selected (ComboBox, Gallery, etc.)

 

As a test, I have a DropDown1 with some items and a Label set to PlanYear.Selected.Value

On a button - Set(PlanYear, DropDown1)
With that, the label has an error.  If I set the label to another property (let's say Visible), it works fine and shows true

 

 

Seems there is an issue with assigning an object and getting to those specific properties.

 

A potential workaround might be to Set(PlanYear, PlanningYear.Selected)

 

Doesn't fix the issue, but may get you past the hurdle.

 

EDIT: Seems to be on any property that returns a table.  For example, setting a variable to a Gallery object and then trying to access the AllItems property yields the same issue.

 

RandyHayes
Level 10

Re: Same version (no changes) works when played - doesn't work when run in editor

Don't know if this will help but I found that UpdateContext DOES work properly.

 

Set(PlanYear, PlanningYear)

Label.Text =  PlanYear.Selected.Value  (produces error)

 

UpdateContext({PlanYear, PlanningYear})

Label.Text = PlanYear.Selected.Value (WORKS)

 

Seeme like a bug to be killed.

So, just depends on how Global you need your variable to be at this point.

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Same version (no changes) works when played - doesn't work when run in editor

Ahh, I see the problem. It looks like it's possible to set a variable to a dropdown control, but you can't reference the Variable.Selected.

 

As a best practice, when declaring a variable to a dropdown or combobox, I set it to:

Set(variable,Dropdown.Selected)

This drills into the dropdown one level deeper. Then you would reference the selected year as:

variable.Value

You would drop .Selected because you've already drilled into it.

RandyHayes
Level 10

Re: Same version (no changes) works when played - doesn't work when run in editor

It's good advice @Mr-Dang-MSFT!

However, I will contend that this is a bug at this point.  The ability to do an UpdateContext and it works, but yet a Set doesn't (and yet it did before) seems like a bug.

And, of course, the function reference states that using Set to set an Object Reference is allowed. Maybe not best practice, but allowed.

LRVinNC
Level: Powered On

Re: Same version (no changes) works when played - doesn't work when run in editor

Thanks @Mr-Dang-MSFT and @RandyHayes for your insights.  

 

I have applied your best practice, Brian, and it does now work correctly. The explanation is much appreciated. 

But I do agree with, @RandyHayes, that it does seem like a regression when it did work just fine before and suddenly stopped working without warning.  

 

Now I can move on to the changes I really DID want to make when I discovered this problem.  

Again, my thanks.