Add Client JavaScript Code to Main Form of Account Table | PL-400 Exam - Microsoft Power Platform Developer

Form Element Events for Client JavaScript Code in Main Form of Account Table

Question

You need to add a client JavaScript code to the Main form of the Account table.

Please select all the form element events that you can register the event handlers for.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answers: B and E

Power Apps provides a Client API model for model-driven apps for users to implement for their business logic.

The Client API model comprises objects and methods that developers can access using JavaScript code.

They can create event handlers.

The event handler includes the reference to the registered JavaScript web resource and the registration of the functions from the JavaScript code that the handler runs on the event occurrence.

There are four form elements that you can register the event handlers for: Form - has two events: OnLoad (when the form loads) and OnSave (when the form's data is saved).

Tab - has one event: TabStageChange (when the tab expands or collapses).

Column - has one event: OnChange (when column data is changed, or control loses focus).

IFrame - has one event: OnReadyStateComplete (when iFrame content loads).

To register an event handler for the JavaScript code on the main form, you need to add the code as a web resource to the library.

You open the Dataverse table's main form (Number 1), and on the Form libraries panel, push the "Add library" button (Number 3)

After you register JavaScript as a web resource, it will be added to the library and appear on the Form libraries panel (Number 4)

Then you switch to the Events tab (number 5)

There are two events for the form: OnSave (Number 6) and OnLoad.

When you open the OnSave or OnLoad sections, you can register an event handler using the "+ Event Handler" button (Number 7)

This button opens the "Configure Event" pop-up (Number 8), where you can register the JavaScript function (Number 9) for this event handler.

Power Apps | Form

Back Ie

Form libraries 2)

P Search

+ Add libran

++ Form field -+ Component [E Form settings Switch to classic

New Account
Account

Summary Details

ACCOUNT INFORMATION

Account Name =

Phone =

Fax

Website

Parent Account

Ticker Symbol

ADDRESS

Address 1: Street 7

Address 1: Street 2

Address 1: Street 3 oe

Address 1: City _
Address 1:
State/Province

Address 1: ZIP/Postal
Code

Address 1:
‘Country/Region

Map is disabled for this organization.

| Active

® Get Directions

Timeline

Almost there

Configure Event

Event Type
On Save nd
Library
v

cr78c_cbclientapicode

Function *

MyFunction|

@ Enabled

parameter

Pass execution context as first

Comma separated list of parameters
that will be passed to the function

Seneca

T Desktop (1920 x 1080) VW

+ 65%

Tons]

Save \~ E Publish

Account »
Main form 6
Properties Events

++ Event Handler

+ Event Handler

Option A is incorrect because the OnReadyStateComplete is the IFrame's event, but it is not a Form's event.

Option C is incorrect because the OnChange is the Column's event, but it is not a Form's event.

Option D is incorrect because the TabStateChange is the Tab's event, but it is not a Form's event.

For more information about the Dataverse event handler registration, please visit the below URLs:

Sure, I'd be happy to help!

When working with the Main form of an entity in the Power Platform, you can register event handlers for various form element events. These events allow you to perform custom actions when specific actions are taken by the user, such as loading the form or changing the value of a field.

Let's take a look at each of the events listed and what they do:

A. OnReadyStateComplete: This event occurs when the state of the form is fully loaded and ready to be manipulated. You can use this event to perform custom actions after the form has finished loading.

B. OnLoad: This event occurs when the form is first loaded. You can use this event to perform custom actions when the form is initially displayed to the user.

C. OnChange: This event occurs when the value of a field on the form is changed. You can use this event to perform custom actions when the user changes the value of a particular field.

D. TabStateChange: This event occurs when the user navigates to a different tab on the form. You can use this event to perform custom actions when the user switches between tabs on the form.

E. OnSave: This event occurs when the user saves changes to the form. You can use this event to perform custom actions when the user saves changes to the entity record.

So, to answer the question, the form element events that you can register event handlers for are:

  • OnLoad
  • OnChange
  • OnSave

Therefore, the correct answers are B, C, and E.