PL-400 practice question 12 of 35

You need to add the script to populate event data on the form. Which code segment should you use?

Full set: 391 questions

Domain Create and configure Power Apps

Answer options
A: formContext.data.addOnLoad(myFunction) Correct answer
B: formContext.data.removeOnLoad(myFunction)
C: formContext.data.entity.addOnSave(myFunction)
D: addOnPreProcessStatusChange
E: formContext.data.isValid()
Correct Answer:
A. formContext.data.addOnLoad(myFunction)
Explanation

The formContext.data.addOnLoad method is the correct client API function to register a script that executes when a model-driven app form finishes loading. This event is the appropriate trigger for populating or manipulating data as the form is initially presented to the user. The method adds a specified function, in this case myFunction, to the OnLoad event handler pipeline for the form.

Why Incorrect

B. formContext.data.removeOnLoad(myFunction): This method removes a function from the OnLoad event handler, which is the opposite of the required action.
C. formContext.data.entity.addOnSave(myFunction): This method registers a function to run during the OnSave event, which occurs when the user tries to save the record, not when the form loads.
D. addOnPreProcessStatusChange: This method is part of the business process flow object (formContext.data.process) and is used for events related to BPF stage changes, not the main form load event.
E. formContext.data.isValid(): This is a method that returns a boolean value indicating if the form data is valid. It does not register an event handler to run code. ---

References

1. Microsoft Learn Documentation: formContext.data.addOnLoad. This document explicitly states, "Adds a function to be called when the form is loaded." This directly supports the use of this method for running scripts on form load.

Source: Microsoft, "Client API formContext.data object," Microsoft Learn, formContext.data.addOnLoad section.

2. Microsoft Learn Documentation: Events in model-driven apps. This page describes the form event pipeline, identifying OnLoad as the event that occurs when the form has loaded. It contrasts this with the OnSave event.

Source: Microsoft, "Events in model-driven apps," Microsoft Learn, "Form events" section.

3. Microsoft Learn Documentation: formContext.data.entity object. This document details the addOnSave method, confirming it is used for the save event, making it unsuitable for a form load scenario.

Source: Microsoft, "Client API formContext.data.entity object," Microsoft Learn, addOnSave section.

Scroll to Top