Summary
You can now apply client-side logic, including scripting, data access, commands, and UI feedback, to a model-driven app form so it responds to data and user actions in real time. Across the equipment-provisioning scenario, the Request form validates what an employee enters and retrieves current data from Dataverse. It also guides both the employee and the coordinator toward the right next step at each stage of a request.
What you learned
- You target form data through
formContext, retrieved from the execution context'sgetFormContext()method. You also decide between UI-based and code-based event handler registration, depending on whether the Events tab exposes the event and whether the handler needs to attach or detach at runtime. - You read and write Dataverse data from a client script with the asynchronous
Xrm.WebApimethods. You also choose Power Fx or JavaScript to define a command'sOnSelectandVisiblelogic. That choice depends on whether the command stays simple and data-driven, or needs direct Web API calls, server-side action execution, or a function you already wrote for a form script. - You guide the coordinator through the approval process with three tools.
Xrm.Navigation.navigateToopens a related record without losing the Request form.openConfirmDialogconfirms an action before it runs. And the right notification mechanism, a single field, the current form, or the entire app, delivers feedback at the right scope.