cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
remariu
Advocate I
Advocate I

Set variable on visible giving error

I have defined a global variable (varApprove) with a boolean condition.  I want to reset the variable to false when I navigate to a specific screen.  I have tried to use Set(varApprove, false) at the OnVisible command, but I'm getting the following error:

 

"Unexpected Characters.  The formula contains "Ident" where "PowerFXResolvedObject" is expected."

 

Does anyone know what this means?  

 

1 ACCEPTED SOLUTION

Accepted Solutions

@remariu 

 

For me, this setting comes by default as On. If so , you must use App.OnStart.

 

You say you want to explicitly turn it off?

So if you turn it off, Save the app, and then refresh the browser.

 

However, I don't know if it is going away in the future, even if the new stuff is implemented at some point. Without App.OnStart, there's currently no way to put anything there OnStart, App.StartScreen just is a new way to tell you the StartScreen and nothing else, and you can use this with App.OnStart enabled or disabled. You need to just use OnVisible of the first screen instead then if you want to have no App.OnStart. 

 

If you really want to get rid of your App.OnStart property, what you can do is have a first screen, then leave this first screen blank, put a Timer control in this first Screen, duration 100 (or if it's too low, try 500), AutoStart true, and OnTimerEnd put all your formulas that set all the variables and then as the very last line, Navigate(someOtherScreen) away from it, and never return to this screen again elsewhere in your app. You can't use Navigate in an OnVisible of a Screen directly, it won't let you do that, so the Timer is necessary.

 

To test in editor, always click Navigate to StartScreen to do so. Note that Timers may not run in the Editor directly, and might only in the Preview of the Editor, so if you don't want to use Preview, you'll need to manually click the first Screen of your app (or manually click on Navigate to StartScreen)

poweractivate_0-1665510211169.png

(yes, I have no Run OnStart option in the above - this is intentionally missing, it's exactly how it looks when the setting you referred to is turned Off)

 

and then manually click the other screen the Timer goes to (say the second screen) each time you want to test your app from a clean run directly in the editor without explicitly or necessarily "previewing" it in the editor.

 

For StartScreen just set it to the first screen of the App (or maybe even leave it blank if it lets you do so, since the default might be just to load the first screen of the app anyway, but if you want, explicitly set App.StartScreen to the first screen of the App).

 

To my knowledge and awareness, there is no App.Formulas property, nor are any of the declarative approaches described in that blog post implemented as of yet, so the above might be the closest in order to really use the new features you are talking about.

 

See if it helps @remariu 

 

 

View solution in original post

10 REPLIES 10

@remariu 

 

I never saw this issue before.

 

A. Try to change the variable name to something else like myVarApproval.

Does it work?

 

B. Try copying the below line exactly from this forum post, into the formula giving the error.

 

Set(myVarApprovalBool,false)

 

and then copy and paste the below line from this forum to everywhere you have the old variable name

 

myVarApprovalBool

 

Is there still an issue?

 

C. Manually retype all formulas that have the variable name anywhere in it, and use yet another variable name.

 

If none of the above helps, 

 

Try the steps below in case it helps:

 

NOTE: if the below steps actually work, they may stop working at any time in the future and you should also follow the steps at the bottom of this post to start a support ticket, especially if the following steps "seem to resolve the issue"

 

NOTE: The below previous version 3.22085.14 may no longer be available to switch to so the below steps may not work at all. 

If that's the case and nothing else above worked, you (or your administrator) should:

Create a new Power Platform Support Ticket using these steps.

 

Here are the relevant steps, just in case:

 

1. Click Settings

2. Click Support

3. Click Edit

poweractivate_3-1665316353945.png

 

4. Click dropdown Authoring version and select the oldest possible version 3.22085.14 from the dropdown

poweractivate_4-1665316390423.png

 

 

5. Click Reload + apply version

poweractivate_2-1665316347635.png

 

 

Does the issue persist after doing the above steps?

 

If the issue does not persist, it could be an indication that the current authoring version has changed something in an unexpected way. If so,

Create a new Power Platform Support Ticket

because even if reverting the authoring version works now, it may stop working at any time in the future, so you should contact support and report the issue.

 

Even if the issue doesn't persist, I recommend you should

Create a new Power Platform Support Ticket

just in case,

maybe there is still some issue, the error looks really bizarre and may indicate some issue that you should alert the support team about just in case.

 

See if it helps @remariu 

 

remariu
Advocate I
Advocate I

I think this may have something to do with how I'm initializing this variable.  I used to set many of my global variables at OnStart of the app, but with the abandonment of the OnStart function I can no longer use Set(varApprove, false).  I am now using Formulas and setting the variable as varApprove = false.   The removal of the OnStart functionality has caused a lot of confusion for me and I can't find any documentation on how to work around things that seemed straight forward before.  Is there another way to be setting this variable?

@remariu 

 

If you want to avoid the rules you need to know resulting from this feature  introduction in October 2021: App.StartScreen: a new declarative alternative to Navigate in App.OnStart 

 

Just  use the OnVisible property of the first Screen, and use Set(varApprove, false)

 

Then you can do it with the way you knew before.

 

Does this help @remariu ?

 

I have seen this article, but it only speaks to Navigating from App.StartScreen.  I have not found any documentation on other functions such as setting variables in App.OnStart, which is what I primarily used it for.  I can use the OnVisible command which should work in most cases, but it will automatically reset any variables and there are some cases where I just need to set a variable once when I load and not every time I navigate to the home screen.  I have not found anything on how to effectively use the App.Formulas.  

 

@remariu 

The OnStart property of App still works for me right now, using formulas like Set(someVar,someValue), directly in the OnStart property of App, including in a brand new blank app made from scratch. I do not get any error of a contains Ident where PowerFXResolvedObject expected, or any error at all.

 

What is wrong with it for you?

 

Note than OnStart only triggers automatically in the live, published app.

To trigger it in the editor, click the ellipses to the right of App and then click Run OnStart.

poweractivate_0-1664872794178.png

 

Now click on Variables at the top, see if it worked

poweractivate_0-1665507127329.png

 

 

See if it helps @remariu 

remariu
Advocate I
Advocate I

Yes, I have to actively enable the App.OnStart feature in the settings and can use it, but I'm assuming this feature will be going away so I'm trying to find workarounds and how to deal with this in the future.  I can set a variable using App.Formulas and do not have any troubles with something I don't need to change within the app (i.e., varUserName = User().FullName). But, if I use this to set a variable such as varApprove = false, then I run into the error message later in the app (Unexpected Characters.  The formula contains "Ident" where "PowerFXResolvedObject" is expected) when I try to change the variable value.  So, in the short term, I will either continue to use App.OnStart or the OnVisible property of the home screen to set global variables.  I'm just not sure how to work around this when App.OnStart is no longer supported.

@remariu I didn't have to enable anything and it worked for me.

Are you referring to this Enable Navigate function in App.OnStart ?

 

poweractivate_0-1665507890008.png

 

If so, I recommend you try to turn it off, and then just use App.StartScreen to write the formula specifically and only for which Screen shows first when the App is started. When you do this, you write the formula like this for the StartScreen property of App

//App.StartScreen - pseudo formula example
SomeScreen

or for a more detailed example

//App.StartScreen - pseudo formula example
If
(
   someCondition1
  ,SomeScreen1
  ,If
  (
     someCondition2
    ,SomeScreen2
    ,If
    (
       someCondition3
      ,SomeScreen3
      ,SomeScreen4
    )
)

Other than the above, I am unsure what feature had to be enabled. You can use App.OnStart just like before without enabling the Retired feature above, if you don't currently use any Navigate call inside of it or don't deal with what Screen shows first anywhere in your App.OnStart currently.

 

remariu
Advocate I
Advocate I

First of all, thank you very much for all of your suggestions.  I feel like there is something basic that I am missing.  I used to use the Set(varXXX, YYY) at the App.OnStart, but without this function, I am trying to use App.Formulas and using varXXX = YYY.  I have not been successful in setting a variable using Set(varXXX, YYY) at App.StartScreen.  I have re-enabled the OnStart property at the Settings, General (see below) which allows me to continue to use the App.OnStart property, but I'm assuming this will be going away sometime in the future.

 

remariu_1-1665509227588.png

 

 

 

 

@remariu 

 

For me, this setting comes by default as On. If so , you must use App.OnStart.

 

You say you want to explicitly turn it off?

So if you turn it off, Save the app, and then refresh the browser.

 

However, I don't know if it is going away in the future, even if the new stuff is implemented at some point. Without App.OnStart, there's currently no way to put anything there OnStart, App.StartScreen just is a new way to tell you the StartScreen and nothing else, and you can use this with App.OnStart enabled or disabled. You need to just use OnVisible of the first screen instead then if you want to have no App.OnStart. 

 

If you really want to get rid of your App.OnStart property, what you can do is have a first screen, then leave this first screen blank, put a Timer control in this first Screen, duration 100 (or if it's too low, try 500), AutoStart true, and OnTimerEnd put all your formulas that set all the variables and then as the very last line, Navigate(someOtherScreen) away from it, and never return to this screen again elsewhere in your app. You can't use Navigate in an OnVisible of a Screen directly, it won't let you do that, so the Timer is necessary.

 

To test in editor, always click Navigate to StartScreen to do so. Note that Timers may not run in the Editor directly, and might only in the Preview of the Editor, so if you don't want to use Preview, you'll need to manually click the first Screen of your app (or manually click on Navigate to StartScreen)

poweractivate_0-1665510211169.png

(yes, I have no Run OnStart option in the above - this is intentionally missing, it's exactly how it looks when the setting you referred to is turned Off)

 

and then manually click the other screen the Timer goes to (say the second screen) each time you want to test your app from a clean run directly in the editor without explicitly or necessarily "previewing" it in the editor.

 

For StartScreen just set it to the first screen of the App (or maybe even leave it blank if it lets you do so, since the default might be just to load the first screen of the app anyway, but if you want, explicitly set App.StartScreen to the first screen of the App).

 

To my knowledge and awareness, there is no App.Formulas property, nor are any of the declarative approaches described in that blog post implemented as of yet, so the above might be the closest in order to really use the new features you are talking about.

 

See if it helps @remariu 

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,670)