You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/model-driven-apps/clientapi/events-forms-grids.md
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,16 @@ To add or remove event handler functions to events in the new Unified Interface:
52
52
53
53
---
54
54
55
+
### Bulk edit forms
56
+
57
+
By default, events handlers aren't called when a form is in bulk edit mode.
58
+
59
+
To enable an event handler in bulk edit mode, modify the Form XML by finding the relevant `event` element and creating/setting the `BehaviorInBulkEditForm` attribute to `Enabled`.
60
+
61
+
For more information on Form XML customization, see [When to edit the customizations file](../when-edit-customization-file.md), [Customize forms](../customize-entity-forms.md), and the [Form XML schema](../form-xml-schema.md).
62
+
63
+
To determine when an event handler is called on a form in bulk edit mode use [`getFormType`](reference/formContext-ui/getFormType.md) method.
64
+
55
65
## Add or remove event handler function to event using code
56
66
57
67
Using the following methods to add and remove event handler for events that cannot be associated through UI:
@@ -83,4 +93,4 @@ Use the [setSharedVariable](reference/executioncontext/setSharedVariable.md) and
title: "Form OnLoad event (Client API reference) in model-driven apps| MicrosoftDocs"
3
-
description: Learn how to set the form OnLoad event.
4
-
ms.date: 04/15/2021
3
+
description: Includes description and supported parameters for the OnLoad event.
4
+
ms.date: 12/16/2021
5
5
ms.service: powerapps
6
6
ms.topic: "reference"
7
7
applies_to: "Dynamics 365 (online)"
8
-
ms.assetid: 89123cde-7c66-4c7d-94e4-e287285019f8
8
+
ms.assetid: fb13c0a1-0e00-4592-8e58-3c2412141fbd
9
9
author: "Nkrb"
10
10
ms.author: "nabuthuk"
11
11
manager: "kvivek"
@@ -15,24 +15,49 @@ search.app:
15
15
- PowerApps
16
16
- D365CE
17
17
---
18
-
# Form OnLoad event (Client API reference)
18
+
# Form OnLoad event
19
19
20
-
The form `OnLoad`event occurs after the form has loaded. It also occurs after a record is saved on create or update, and on refresh. For example by selecting the **Save** or the **Refresh** button on the main form. Use the `OnLoad` event to apply logic about how the form should be displayed, to set properties on columns, and interact with other page elements.
20
+
This event occurs whenever form data is loaded, specifically:
21
21
22
-
You can determine in what context the `OnLoad` event occurs by using [getEventArgs](../executioncontext/getEventArgs.md). By doing so, you can apply logic conditional on the context.
22
+
- On initial page load.
23
+
- When the page data is explicitly refreshed using formContext.data.[refresh](../formContext-data/refresh.md) method.
24
+
- When the data is refreshed on a page on saving a record, if there are any changes.
25
+
26
+
Use the formContext.data.[addOnLoad](../formContext-data/addOnLoad.md) and formContext.data.[removeOnLoad](../formContext-data/removeOnLoad.md) methods to manage event handlers for this event.
23
27
24
-
Data for related tables on a form, such as data for subgrids and quick view forms are not guaranteed to be available when the `OnLoad` event handler is executed. Logic that depends on related data should use the [Subgrid OnLoad](./subgrid-onload.md) event, quick view form should use the [isLoaded](../formcontext-ui-quickforms/isloaded.md) function, or the appropriate function for determining when the data should be loaded for the particular related data.
The `OnLoad` event handler has the ability to wait for promises returned by event handlers to settle before loading a form which allows for an OnLoad event to be asynchronous ("async"). The `OnLoad` event becomes async when the event handler returns a promise.
27
31
28
-
Controls and other UI of the form are not guaranteed to be rendered and in the DOM when the `OnLoad` event occurs. Logic in the `OnLoad` event handler cannot prevent the form from loading.
32
+
The form loads when each promise returned by the event handler is resolved. For any promises that are returned, there is a 10 second limit for each promise. After that, the platform considers promises to be timed out. This timeout is applied per promise. For example, if you have five promises returned, the total wait time is 50 seconds.
33
+
Suppose the promise is rejected or timed out. In that case, the form load operation behaves similarly to the current script errors.
29
34
30
-
The form `OnLoad` event is synchronous by default. However, you should **not** make synchronous network requests in an `OnLoad` event handler. This can cause a slow save experience and an unresponsive app. Instead, you should [asynchronous network requests](../../../best-practices/business-logic/interact-http-https-resources-asynchronously.md). Using asynchronous requests will [dramatically improve the performance of form loads](https://powerapps.microsoft.com/blog/turbocharge-your-model-driven-apps-by-transitioning-away-from-synchronous-requests/) compared to using synchronous requests. If a promise is returned by an event handler, the event becomes asynchronous and the form runtime will wait until the promise is settled before allowing the user to interact with the form.
35
+
The `OnLoad` event will only wait for one promise returned per handler. If multiple promises are required, it is recommended to wrap all the promises in the `Promise.all()` method and return the single resulting promise. For multiple handlers that return a promise, we recommend that you create one handler that calls all the events and return a single promise that wraps all required promises. This is to minimize wait times caused by the timeout.
31
36
32
-
You should be careful when using asynchronous code in an `OnLoad` event handler that needs an action to be taken or handled on the resolution of the async code. Asynchronous code can cause issues if the resolution handler expects the app context to remain the same as it was when the asynchronous code has started. For example, there may be code in an `OnLoad` event handler to make a network request and change a control to be disabled based on the response data. Before the response from the request is received, the user may have interacted with the control or navigated to a different page, so there may be undesired behavior. If you need to not show data or UI before the asynchronous requests complete, your code can hide or disable the relevant UI until the requests are complete. Your code should also check that the user is in the same context after each asynchronous continuation point.
37
+
### Enable Async OnLoad using app setting
33
38
39
+
To use async onLoad handlers, you will need to enable it through the app setting.
40
+
An app setting is a platform component that allows you to turn supported features on or off for your app.
41
+
To enable the async Onload event handlers for a specific app:
34
42
43
+
1. Go to https://make.powerapps.com.
44
+
2. Make sure you select the correct environment.
45
+
3. Select **Apps** from the left navigation pane.
46
+
4. Select the app and then select **...** (ellipses). Select **Open in preview**.
When using an async handler, a form load will wait for the promise to be fulfilled. To ensure that a load completes on time, the handler throws a timeout exception after 10 seconds to let you know to tune the async OnLoad event for better performance.
57
+
58
+
There may be scenarios where you want to halt the OnLoad execution, and the timeout will stop the operation from occurring. An example is opening a dialog in the async OnLoad and waiting for the user’s input before saving. To make sure the async operation will wait you can provide the event argument **disableAsyncTimeout**(executioncontext.getEventArgs().disableAsyncTimeout()).
59
+
When the **disableAsyncTimeout is set, the timeout for that handler will not be applied. It will continue to wait for that handler's promise to be fulfilled.
60
+
61
+
This should be used with caution as it might affect the performance of the form load.
Copy file name to clipboardExpand all lines: powerapps-docs/developer/model-driven-apps/clientapi/reference/events/form-onsave.md
+26-37Lines changed: 26 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Form OnSave event (Client API reference) in model-driven apps| MicrosoftDocs"
3
3
description: Includes description and supported parameters for the form OnSave event.
4
-
ms.date: 05/05/2021
4
+
ms.date: 12/16/2021
5
5
ms.service: powerapps
6
6
ms.topic: "reference"
7
7
applies_to: "Dynamics 365 (online)"
@@ -34,9 +34,7 @@ You can cancel the save action by using the preventDefault method within the eve
34
34
35
35
The OnSave event has ability to wait for promises returned by event handlers to settle before saving, allowing the `OnSave` event to be asynchronous ("async").
36
36
37
-
The `OnSave` event becomes async when a promise is returned by an `OnSave` event handler, async OnSave events are enabled by default, if you wish to disable async operations for your `OnSave` handlers, go to [PowerApps](https://powerapps.microsoft.com), select **Solutions** tab , select the solution that has the app and then select **Settings**, and look for “Async onsave handler”, make sure the check box is unchecked. After disabling the option make sure you publish customizations.
38
-
39
-
Saving of the record happens when each promise returned by a handler is resolved. For any promises that are returned, there is a 10-second limit for each promise, after that the platform considers promises to be timed out. This timeout is applied per promise. For example, if we have five promises returned, the total wait time is 50 seconds.
37
+
The `OnSave` event becomes async when a promise is returned by an `OnSave` event handler. Saving of the record happens when each promise returned by a handler is resolved. For any promises that are returned, there is a 10 second limit for each promise, after that the platform considers promises to be timed out. This timeout is applied per promise. For example, if we have 5 promises returned, the total wait time is 50 seconds.
40
38
41
39
If the promise is rejected or timed out, the save operation continues to behave similarly to the current script errors. Use the [preventDefault](../save-event-arguments/preventDefault.md) method within the event arguments object in that particular handler if you want to prevent the save event to happen if there is a script error/rejected promise or handler times out.
42
40
@@ -62,39 +60,30 @@ In this scenario, since there are multiple async processes and both calls return
62
60
> }
63
61
>```
64
62
65
-
### Disable Async OnSave using app setting
66
-
67
-
An app setting is a platform component that allows you to override a setting on an app. App setting should have a unique name and must be in the format `solutionpublisherprefix_appname_settingname`.
68
-
69
-
To disable the async `OnSave` event handlers for a specific app:
70
-
71
-
- Create a new unmanaged solution.
72
-
- Open the newly created solution. Select **Add existing** > **App** > **Model-driven app**.
73
-
- From the list of existing model-driven apps, select the app where you want to see this feature.
74
-
- Publish all customizations.
75
-
- Again from the list of solutions in the solution explorer, select the solution where you have added the model-driven app and then select **Export**. A zip file is downloaded to your local machine.
76
-
- Extract the downloaded zip file. Open the **Customizations.xml** file in your preferred editing tool.
77
-
- Add the following code `AppModule` node in the `customization.xml` file. Setting the `<value>false</value>` to disable async `OnSave` event handler support for that specific app. Any form within this app will be able to get access to the async OnSave functionality.
78
-
79
-
```XML
80
-
<appsettings>
81
-
<appsetting uniquename="MyAppName_AsyncOnSave">
82
-
<iscustomizable>1</iscustomizable>
83
-
<settingdefinitionid>
84
-
<uniquename>AsyncOnSave</uniquename>
85
-
</settingdefinitionid>
86
-
<value>true</value>
87
-
</appsetting>
88
-
</appsettings>
89
-
```
90
-
91
-
- You can verify whether the configuration has been successfully installed using the following request:
92
-
93
-
```http
94
-
GET https://org00000000.crm.dynamics.com/api/data/v9.2/appsettings?$filter=(uniquename eq 'MyAppName_AsyncOnSave')
95
-
Accept: application/json
96
-
Authorization: Bearer ey...
97
-
```
63
+
### Enable Async OnSave using app setting
64
+
65
+
To use async onSave handlers you will need to enable it through an app setting:
66
+
67
+
1. Go to https://make.powerapps.com.
68
+
2. Make sure select the correct environment.
69
+
3. Select **Apps** from the left navigation pane.
70
+
4. Select the app and then select **...** (ellipses). Select **Open in preview**.
When using an async save the handler will wait for the promise to be fulfilled. To ensure that a save completes in a timely manner the handler throws a timeout exception after 10 seconds to let you know to tune the async `OnSave` event for better performance.
81
+
82
+
There may be scenarios where you want to halt the `OnSave` execution, and the timeout will stop the operation from occurring. An example is opening a dialog in the async OnLoad and waiting for the user’s input before saving. To make sure the async operation will wait you can provide the event argument **disableAsyncTimeout**(executioncontext.getEventArgs().disableAsyncTimeout()).
83
+
84
+
When the **disableAsyncTimeout is set, the timeout for that handler will not be applied. It will continue to wait for that handler's promise to be fulfilled.
85
+
86
+
This should be used with caution as it might affect the performance of the form save.
Copy file name to clipboardExpand all lines: powerapps-docs/user/relevance-search.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ manager: kvivek
6
6
ms.service: powerapps
7
7
ms.component: pa-user
8
8
ms.topic: conceptual
9
-
ms.date: 10/25/2021
9
+
ms.date: 12/16/2021
10
10
ms.subservice: end-user
11
11
ms.author: mkaur
12
12
ms.custom: ""
@@ -66,7 +66,7 @@ With suggestions, you can access your information quickly by using minimal keyst
66
66
67
67
## Search results page
68
68
69
-
View the full results for a search by pressing **Enter** on your keyboard or selecting **Show more results**.
69
+
View the full results for a search by pressing **Enter** on your keyboard or selecting **Show more results**. Dataverse search will append "\*" to the search if two or less characters are entered.
70
70
71
71
Search results are ranked based on relevance and grouped by tables. The list of tables that include rows that match the search term are displayed horizontally as tabs along the top of the screen.
0 commit comments