PL-400 · Question #458
A model-driven app form has JavaScript that runs during the OnLoad event. The event retrieves an account record and changes visibility to a form column based on one of the record columns. The…
The correct answer is C. Enable the Async OnLoad app setting. Your model-driven app form loads slowly because the default OnLoad event is synchronous, meaning it blocks form rendering while waiting for Xrm.WebApi.retrieveRecord to complete, but enabling the Async OnLoad setting makes these handlers asynchronous, allowing the form to load…
Question
Options
- AUse a synchronous XMLHttpRequest instead.
- BAdd the code to change visibility to the success callback.
- CEnable the Async OnLoad app setting.
- DSet the options parameter to return only the column required.
- EStore the returned data in a global variable.
How the community answered
(44 responses)- A2% (1)
- B2% (1)
- C77% (34)
- D11% (5)
- E7% (3)
Explanation
Your model-driven app form loads slowly because the default OnLoad event is synchronous, meaning it blocks form rendering while waiting for Xrm.WebApi.retrieveRecord to complete, but enabling the Async OnLoad setting makes these handlers asynchronous, allowing the form to load first and the JavaScript to run in the background, significantly improving perceived performance. To fix this, enable Async OnLoad in your app's settings and refactor your JavaScript to use modern async patterns (like async/await) with Xrm.WebApi calls, as synchronous Web API calls are discouraged for performance. Using a synchronous XMLHttpRequest in a model-driven app's OnLoad event does make the form load faster initially because it blocks rendering until data arrives, but it's a bad practice that freezes the UI, leading to poor user experience and potential timeouts. https://learn.microsoft.com/en-us/power-apps/developer/model-driven- apps/clientapi/reference/events/form-onload
Community Discussion
No community discussion yet for this question.