Skip to content

Commit 562c7ed

Browse files
authored
Merge pull request #1667 from MicrosoftDocs/master
Publish: add topic about the App object, including ConfirmExit
2 parents afe9588 + eddac0e commit 562c7ed

File tree

9 files changed

+133
-23
lines changed

9 files changed

+133
-23
lines changed

powerapps-docs/maker/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
- name: And
351351
href: ./canvas-apps/functions/function-logicals.md
352352
- name: App
353-
href: ./canvas-apps/functions/signals.md
353+
href: ./canvas-apps/functions/object-app.md
354354
- name: Asin
355355
href: ./canvas-apps/functions/function-trig.md
356356
- name: AsType

powerapps-docs/maker/canvas-apps/formula-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Other elements include:
4141

4242
**[And](functions/function-logicals.md)** – Boolean logic AND. Returns **true** if all arguments are **true**. You can also use the [**&&** operator](functions/operators.md).
4343

44-
**[App](functions/signals.md)**Returns information about the currently running app, such as which screen is currently displayed.
44+
**[App](functions/object-app.md)**Provides information about the currently running app and control over the app's behavior.
4545

4646
**[Asin](functions/function-trig.md)** – Returns the arcsine of a number, in radians.
4747

Binary file not shown.
Loading
Loading
Loading
Loading
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: App object | Microsoft Docs
3+
description: Reference information, including syntax and examples, for the App object in PowerApps
4+
author: gregli-msft
5+
manager: kvivek
6+
ms.service: powerapps
7+
ms.topic: reference
8+
ms.custom: canvas
9+
ms.reviewer: anneta
10+
ms.date: 05/29/2019
11+
ms.author: gregli
12+
search.audienceType:
13+
- maker
14+
search.app:
15+
- PowerApps
16+
---
17+
# App object in PowerApps
18+
19+
Provides information about the currently running app and control over the app's behavior.
20+
21+
## Description
22+
23+
Like a control, the **App** object provides properties that identify which screen is showing and that prompt the user to save changes so that they're not lost. Every app has an **App** object.
24+
25+
You can write formulas for some properties of the **App** object. At the top of the **Tree view** pane, select the **App** object as you would any other control or screen. View and edit one of the object's properties by selecting it in the drop-down list to the left of the formula bar.
26+
27+
> [!div class="mx-imgBorder"]
28+
> ![The App object in the Tree view pane](media/object-app/appobject.png)
29+
30+
## ActiveScreen property
31+
32+
The **ActiveScreen** property identifies the screen that's showing.
33+
34+
This property returns a screen object, which you can use to reference properties of the screen or compare to another screen to determine which screen is showing. You can also use the expression **App.ActiveScreen.Name** to retrieve the name of the screen that's showing.
35+
36+
Use the **[Back](function-navigate.md)** or **[Navigate](function-navigate.md)** function to change the screen that's showing.
37+
38+
## OnStart property
39+
40+
The **OnStart** property runs when the user starts the app. App makers often use this property to perform these tasks:
41+
42+
- Retrieve and cache data into collections by using the **[Collect](function-clear-collect-clearcollect.md)** function.
43+
- Set up global variables by using the **[Set](function-set.md)** function.
44+
- Navigate to an initial screen by using the **[Navigate](function-navigate.md)** function.
45+
46+
This formula is evaluated before the first screen appears. No screen is loaded, so you can't set context variables with the **[UpdateContext](function-updatecontext.md)** function. However, you can pass context variables with the **Navigate** function.
47+
48+
After you change the **OnStart** property, test it by hovering over the **App** object in the **Tree view** pane, selecting the ellipsis (...) that appears, and then selecting **Run OnStart**. Unlike when the app is loaded for the first time, existing collections and variables will already be set. To start with empty collections, use the **[ClearCollect](function-clear-collect-clearcollect.md)** function instead of the **Collect** function.
49+
50+
> [!div class="mx-imgBorder"]
51+
> ![App-item shortcut menu for Run OnStart](media/object-app/appobject-runonstart.png)
52+
53+
## ConfirmExit properties
54+
55+
Nobody wants to lose unsaved changes. Use the **ConfirmExit** and **ConfirmExitMessage** properties to warn the user before they close your app.
56+
57+
> [!NOTE]
58+
> **ConfirmExit** doesn't work in apps that are embedded in, for example, Power BI and SharePoint.
59+
60+
> [!NOTE]
61+
> At present, these properties can reference controls on only the first screen if the **Delayed load** preview feature is enabled (which it is by default for new apps). If references are made, PowerApps Studio doesn't show an error, but the resulting published app doesn't open in PowerApps Mobile or a browser. We're actively working to lift this limitation. In the meantime, you can turn off **Delayed load** in **File** > **App settings** > **Advanced settings** (under **Preview features**).
62+
63+
### ConfirmExit
64+
65+
**ConfirmExit** is a Boolean property that, when *true*, opens a confirmation dialog box before the app is closed. By default, this property is *false*, and no dialog box appears.
66+
67+
Use this property to show a confirmation dialog box if the user has made changes but not saved them. Use a formula that can check variables and control properties (for example, the **Unsaved** property of the [**Edit form**](../controls/control-form-detail.md) control).
68+
69+
The confirmation dialog box appears in any situation where data could be lost, as in these examples:
70+
71+
- Running the [**Exit**](function-exit.md) function.
72+
- If the app is running in a browser:
73+
- Closing the browser or the browser tab in which the app is running.
74+
- Selecting the browser's back button.
75+
- If the app is running in PowerApps Mobile (iOS or Android):
76+
- Running the [**Launch**](function-param.md) function.<br>The **Launch** function doesn't trigger the dialog box in a browser because another tab opens so that data isn't lost.
77+
- Swiping to switch to a different app in PowerApps Mobile.
78+
- Selecting the back button on an Android device.
79+
80+
The exact look of the confirmation dialog box might vary across devices and versions of PowerApps.
81+
82+
The confirmation dialog box doesn't appear in PowerApps Studio.
83+
84+
### ConfirmExitMessage
85+
86+
By default, the confirmation dialog box shows a generic message, such as **"You may have unsaved changes."** in the user's language.
87+
88+
Use **ConfirmExitMessage** to provide a custom message in the confirmation dialog box. If this property is *blank*, the default value is used. Custom messages are truncated as necessary to fit within the confirmation dialog box, so keep the message to a few lines at most.
89+
90+
In a browser, the confirmation dialog box might appear with a generic message from the browser.
91+
92+
### Example
93+
94+
1. Create an app that contains two form controls, **AccountForm** and **ContactForm**.
95+
96+
1. Set the **App** object's **ConfirmExit** property to this expression:
97+
98+
```powerapps-dot
99+
AccountForm.Unsaved Or ContactForm.Unsaved
100+
```
101+
102+
This dialog box appears if the user changes data in either form and then tries to close the app without saving those changes.
103+
104+
> [!div class="mx-imgBorder"]
105+
> ![Generic confirmation dialog box](media/object-app/confirm-native.png)
106+
107+
1. Set the **App** object's **ConfirmExitMessage** property to this formula:
108+
109+
```powerapps-dot
110+
If( AccountsForm.Unsaved,
111+
"Accounts form has unsaved changes.",
112+
"Contacts form has unsaved changes."
113+
)
114+
```
115+
116+
This dialog box appears if the user changes data in the Account form and then tries to close the app without saving those changes.
117+
118+
> [!div class="mx-imgBorder"]
119+
> ![Form-specific confirmation dialog box](media/object-app/confirm-native-custom.png)

powerapps-docs/maker/canvas-apps/functions/signals.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@ ms.service: powerapps
77
ms.topic: reference
88
ms.custom: canvas
99
ms.reviewer: anneta
10-
ms.date: 11/07/2015
10+
ms.date: 05/29/2019
1111
ms.author: gregli
1212
search.audienceType:
1313
- maker
1414
search.app:
1515
- PowerApps
1616
---
1717
# Acceleration, App, Compass, Connection, and Location signals in PowerApps
18-
Returns information about the app's environment, such as where the user is located in the world and which screen is displayed.
18+
19+
Returns information about the app's environment, such as where the user is located in the world and which screen is displayed.
1920

2021
## Description and syntax
21-
All signals return a [record](../working-with-tables.md#records) of information. You can use and store this information as a record, or you can extract individual properties by using the **.** [operator](operators.md).
22+
23+
Signals are values that can change at any time, independent of how the user may be interacting with the app. Formulas that are based on signals automatically recalculate as these values change.
24+
25+
Signals typically return a [record](../working-with-tables.md#records) of information. You can use and store this information as a record, or you can extract individual properties by using the **.** [operator](operators.md).
2226

2327
> [!NOTE]
2428
> The **Acceleration** and **Compass** functions return accurate values in a native player such as on iOS or Android, but those functions return zero values as you create or modify an app in the browser.
2529
2630
### Acceleration
31+
2732
The **Acceleration** signal returns the device's acceleration in three dimensions relative to the device's screen. Acceleration is measured in *g* units of 9.81 m/second<sup>2</sup> or 32.2 ft/second<sup>2</sup> (the acceleration that the Earth imparts to objects at its surface due to gravity).
2833

2934
| Property | Description |
@@ -33,28 +38,14 @@ The **Acceleration** signal returns the device's acceleration in three dimension
3338
| **Acceleration.Z** |Up and down. Up is a positive number. |
3439

3540
### App
36-
The **App** signal returns information about the running app.
37-
38-
| Property | Description |
39-
| --- | --- |
40-
| **App.ActiveScreen** | Screen that's displayed. Returns a screen object, which you can use to reference properties of the screen or compare to another screen to determine which screen is displayed. To change the displayed screen, use the **[Back](function-navigate.md)** or **[Navigate](function-navigate.md)** function. |
41-
| **App.Width** | Returns the width of the window in which the app is running. You can use this property in a formula when you set the **Width** property of the screen to build a responsive app. |
42-
| **App.Height** | Returns the height of the window in which the app is running. You can use this property in a formula when you set the **Height** property of the screen to build a responsive app. |
43-
| **App.DesignWidth** | Returns the width of the app in PowerApps Studio. You can use this property in a formula when you set the **Width** property of the screen to ensure a minimum width in a responsive app. |
44-
| **App.DesignHeight** | Returns the height of the app in PowerApps Studio. You can use this property in a formula when you set the **Height** property of the screen to ensure a minimum height in a responsive app. |
45-
| **App.SizeBreakpoints** | A single-column table of numbers that delimit the screen-size ranges that the [**Screen.Size**](../controls/control-screen.md) property returns. The values in this table may be changed to customize the breakpoints that all of the app's screens use.
4641

47-
The **App** object also has a [behavior formula](../working-with-formulas-in-depth.md) that you can set.
42+
Among other properties, the **App** object includes a signal that indicates which screen is showing.
4843

49-
| Property | Description |
44+
| Property | Description |
5045
| --- | --- |
51-
| **App.OnStart** | The behavior of the app when the user starts it. Makers often use this property to retrieve and cache data into collections with the **[Collect](function-clear-collect-clearcollect.md)** function, set up variables with the **[Set](function-set.md)** function, and navigate to an initial screen with the **[Navigate](function-navigate.md)** function. This formula is evaluated before the first screen appears. No screen is loaded, so you can't set context variables with the **[UpdateContext](function-updatecontext.md)** function. However, you can pass context variables with the **Navigate** function. |
52-
53-
The **App** object appears at the top of the hierarchical list of controls in the left navigation pane, and you can select this object like a control on a screen. After you select the object, you can view and edit one of its properties if you select that property in the drop-down list to the left of the formula bar.
54-
55-
After you change the **OnStart** property, you can test it by hovering over the **App** object in the left navigation pane, selecting the ellipsis (...) that appears, and then selecting **Run OnStart**. Unlike when the app is loaded for the first time, existing collections and variables will already be set. Use the **[ClearCollect](function-clear-collect-clearcollect.md)** function instead of the **Collect** function to start with empty collections.
46+
| **App.ActiveScreen** |Screen that's showing. Returns a screen object, which you can use to reference properties of the screen or compare to another screen to determine which screen is showing. You can use the **[Back](function-navigate.md)** or **[Navigate](function-navigate.md)** function to change the screen that's showing. |
5647

57-
![App item context menu with Run OnStart](media/appobject-runonstart.png)
48+
More information: [**App** object](object-app.md) documentation.
5849

5950
### Compass
6051
The **Compass** signal returns the compass heading of the top of the screen. The heading is based on magnetic north.

0 commit comments

Comments
 (0)