When declaring defined values in Power Apps, declare them in App.Formulas, not App.OnStart

Until now, the defined values used in the app have been defined as global variables in the “App.OnStart” property, but now that the new “App.Formulas” property has been added, I tried it out.

スポンサーリンク

Previously, the definition values were declared using the Set function in the App.OnStart property

In the past, the declaration of defined values to be used throughout the app was often done with the App.OnStart property, as shown below.

Of course, there was nothing wrong with the functionality, but there were problems as shown below.

  • It’s set at app startup, so depending on the value, startup time will be slower.
  • Expression in App.OnStart property increases and is difficult to read
  • The declared definition value can be rewritten

The new functionality added to this is the “App.Formulas” property, which allows you to declare defined values to be used in the app.

App.Formulas

Formulas can declare defined values as follows,
Declared values can thus be used like ordinary variables.

Advantages of App.Formulas

According to the formula, compared to global variables, values declared in App.Formulas have these advantages

  • Formula values are always available
  • Formula values are always up-to-date
  • The definition of the formula is invariant.
  • Can delay the computation of formulas
  • Formulas are managed by a name manager and automatically recalculated

Formula values are always available

Values declared in App.Formulas can be used without considering timing as long as they do not create circular references.

I can use the declared value in App.OnStart,
It can also be used with App.OnStartScreen.
Incidentally, you can also declare/use the defined values in App.Formulas in any order.

Formula values are always up-to-date

Formulas to define values obtained from the data source, these defined values will be automatically updated when the data source is updated (no need to reassign them like a Set).

For example, I found this value in the SPO list,
Define the value obtained from here.
Then, the SPO list was updated,
When the data source is updated on the application side,
It automatically updates the defined values.

This may be useful, for example, when storing per-user settings for apps in Dataverse or SPO lists.

The definition of the formula is invariant.

Values defined in Set can be rewritten, but those defined in App.Formulas cannot.。

This will prevent accidental rewriting of the definition values.

Can delay the computation of formulas

Values declared in App.Formulas are calculated at the time they are needed, which also reduces startup time.

For example, if a defined value that is not used on the top screen is declared in App.OnStart, that defined value will be calculated/set when the app starts.

In contrast, declaring a defined value in App.Formulas reduces OnStart’s load considerably because the declared value is calculated/set when it is needed.

Formulas are managed by a name manager and automatically recalculated

I didn’t understand this last one, but for the moment, the original text.

Named formulas is an Excel concept. Power Fx leverages Excel concepts where possible since so many people know Excel well. Named formulas are the equivalent of named cells and named formulas in Excel, managed with the Name Manager. They recalc automatically like a spreadsheet, just like control properties do.
The point is that it says it will be calculated automatically, so for example, if you declare a defined value that uses the value of the app’s control, like this,
I think what you are trying to say is that whenever the value of the control changes, the definition value is also updated.

(I can’t think of any at the moment.) This could be a use for this somewhere else.

So the newly added App.Formulas property is quite useful and should be used actively.

Related Articles

コメント

Copied title and URL