PL 400: Register an event handler (Apply business logic using client scripting)

In Power App model driven apps, JavaScript is used to perform actions in the form of scripts, ribbon commands, and web resources. Declarative business rules come with limits, so we can use JavaScript to implement custom business logic. In model driven app forms, client scripting provides an object model with methods for interacting with the form component. To use scripting features, form scripts must be uploaded as script web resources. For the execution of script methods, we need to use event handlers.
An event handler is a callback method that operates asynchronously and handles input received in an event.

Event : An event is an action that occurs as a result of a user or other sources.
Event Handler: An event handler is a method that deals with events.

Script web resources can be used to maintain libraries of client script functions that are written in either JavaScript or TypeScript and can be accessed within a model driven app form or from a command bar ribbon definition. Client scripting logic runs event handlers for form events. The use of form properties creates a static configuration of event handlers at design time. In the form designer, we can register event handlers for the following events:

Form : This allows us to register OnLoad and OnSave event handlers.
Tabs: This allows us to register events for each tab on the form for tab state change.
Columns: This allows us to register and even handler if column data is changed.

To upload the script web resources:

Select the web resources:


Upload the script:


Client Scripting logic runs as event handlers for form events:
  • We need to register the event handler to execute the logic
  • Registration for general events can be done through the form.
  • Some events can only be registered from code.
  • Event handlers can run in multiple forms but must be registered for each separately.



Comments

Popular posts from this blog

Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Effective Strategies for Debugging Plugins in Dynamics CRM