Apply business logic using client scripting in model-driven apps using JavaScript

Client-side scripting using JavaScript is one of the ways to apply custom business process logic for displaying data on a form in a Model-driven app, but it shouldn't be your first choice. Business rules provide a way for someone who does not know JavaScript and is not a developer, to apply business process logic in a form. More information: Create business rules to apply logic

Tip

You will find the business rule designer within the Common Data Service area on powerapps.com. When you view an entity, look for the Business rules tab.

If your business requirement can't be achieved using a business rule, you will find that client-scripting using the client API object model provides a powerful way to extend the behavior of the application and enable automation in the client.

Use client scripting in model-driven apps

Forms in Model-driven apps help display data to the user. A form in Model-driven apps can contain items such as fields, a quick form, or a grid. An event occurs in Model-driven apps forms whenever:

  • A form loads
  • Data is changed in a field or an item within the form
  • Data is saved in a form

You can attach your JavaScript code to "react" to these events so that your code gets executed when the event occurs on the form. You attach your JavaScript code (scripts) to these events by using a Script web resource in Model-driven apps.

Model-driven apps provides you a rich set of client APIs to interact with form objects and events to control what and when to display on a form.

Note

Some client APIs are deprecated in the current release of Model-driven apps. Ensure that you are aware of these APIs as you write your client-side code for Model-driven apps. More information: Deprecated client APIs

Get started here

Events in forms and grids
Understand the Client API object model
Walkthrough: Write your first client script

Reference

Client API reference

Web resources for Model-driven apps
Customize commands and the ribbon