Редактиране

Споделяне чрез


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.

Important

All the client scripting concepts and APIs explained in this documentation also apply to Dynamics 365 Customer Engagement (on-premises) users.

Client scripting shouldn't be your first choice though for applying custom business process logic in model-driven app forms. 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. You will find the business rule designer within the Data > Tables > [table_name] area on make.powerapps.com. When you view table, look for the Business rules tab.

However, 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 columns, a quick form, or a grid. An event occurs in model-driven apps forms whenever:

  • A form loads.
  • Data is changed in a column 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