Skip to content

Commit 117033b

Browse files
authored
Update form onload description with what info is guaranteed
1 parent e0501be commit 117033b

File tree

1 file changed

+10
-4
lines changed
  • powerapps-docs/developer/model-driven-apps/clientapi/reference/events

1 file changed

+10
-4
lines changed

powerapps-docs/developer/model-driven-apps/clientapi/reference/events/form-onload.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Form OnLoad Event (Client API reference) in model-driven apps| MicrosoftDocs"
3-
ms.date: 10/31/2018
3+
ms.date: 12/14/2020
44
ms.service: powerapps
55
ms.topic: "reference"
66
applies_to: "Dynamics 365 (online)"
@@ -18,13 +18,19 @@ search.app:
1818

1919

2020

21-
The form `OnLoad` event occurs after the form has loaded. It also occurs after a record is created, for example by selecting the **Save** button on the main form. It cannot prevent the window from loading. Use the `OnLoad` event to apply logic about how the form should be displayed, to set properties on fields, and interact with other page elements.
21+
The form `OnLoad` event occurs after the form has loaded. It also occurs after a record is created, for example by selecting the **Save** button on the main form. Use the `OnLoad` event to apply logic about how the form should be displayed, to set properties on fields, and interact with other page elements.
2222

23-
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.
23+
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.
24+
25+
Data for related entities on a form, such as data for subgrids and quick view forms, are not guaranteed to be available when an `OnLoad` event handler is executed. Logic that depends on related data should use the subgrid onload event, the quick view form isLoaded function, or the appropriate manner for determining when related data is loaded for the particular related data.
26+
27+
Controls on the form are not guaranteed to be rendered when the `OnLoad` event occurs.
28+
29+
Logic in an `OnLoad` event handler cannot prevent the form from loading.
2430

2531
The form `OnLoad` events are synchronous. 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 can make asynchronous network requests.
2632

27-
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 receieved, the user may have interacted with the control or navigated to a different page, so there may be undesired behavior.
33+
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 receieved, the user may have interacted with the control or navigated to a different page, so there may be undesired behavior.
2834

2935

3036

0 commit comments

Comments
 (0)