Plugin vs Entity scoped business rules

In Dataverse, a business rule is a declarative way to apply a set of conditions and actions in the system. Business rules in Dataverse can be scoped at the entity level and at the form level.

The scope of a business rule in Dataverse determines which records and forms the rule applies to. There are three scope options for business rules in Dataverse:

  1. Entity: When you create a business rule with an entity scope, it applies to all forms and run on the server. For example, a business rule with an entity scope of “Account” would apply to all Account forms and even it applies to the data when there is a change in the backend.
  2. Form: When you create a business rule with a form scope, it applies only to the specific form you select. For example, a business rule with a form scope of “Account Main Form” would apply only to the Account Main Form.
  3. All Forms: When you create a business rule with a scope of “All Forms“, it applies to all forms for the entity. This can be useful if you have multiple forms for an entity and want the same business rule to apply to all of them.

The scope of a business rule in Dataverse can be set when creating the rule, and can be changed later if needed. To change the scope of a business rule, you will need to deactivate the rule, change the scope, and then reactivate the rule.

It’s important to carefully consider the scope of a business rule and make sure it’s set to the most appropriate level for the specific use case. Scoping a business rule too broadly can affect the performance of the system, while scoping it too narrowly may not achieve the desired results.

Entity scope runs on the server side compare to the other two scopes that are form specific which runs on the client side. This means that you do not need the form for the rules to be executed. It can also be executed when you do updates to a record programmatically similar to the concept of Workflows and Plugins. They are easy to create and maintain, and do not require programming knowledge.

We need to chose very carefully as we don’t want to scatter your logic sit everywhere in the application. If you have serious of operations and you already have a plugin written for it, then it is wise to put everything in you plugin code. Entity scope business rules is a wonderful tool if your implementation is low code and no code and not so much complex operation happening around.

In summary, plugins are more powerful and flexible, but require development expertise and can be more complex to maintain. Business rules are easier to create and maintain, but have less flexibility and are designed for simpler use cases.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s