TS Logo
Published on

What are Dataverse Business Rules?

Authors
  • avatar
    Name
    Tom Senior
    Twitter
    mailtom@tomsenior.netlinkedintom-senior

Overview

An important Microsoft Dataverse feature at our disposal is Business Rules, they allow us to keep our data accurate and consistent. This makes data easier to work and develop with.

What can Business Rules do?

  • Set Values - We can set values in specified columns depending on the data in another column. For example, maybe you want to calculate the tax value of a price you could use Tax Value Column = 20% of Price Column.
  • Clear Values - Similar to setting values, we can also clear values in an existing column.
  • Validate Data and present error messages - We can check that data is what we are expecting and present error messages if needed. For example lets say we are inputting data on car parts. We only want to input parts that cost less than £500, we can do something like Price > £500 THEN Show Error "Price is above £500".
  • Set Requirement level - We can set whether a field is required or optional.
  • Show or hide Columns*
  • Enable or disable columns* - We can set columns to be read-only or editable.
  • Create business recommendations* - We can create recommendations to show our end users when running through a form.

*These capabilities only apply to Model Driven Power Apps. Its worth noting these capabilities all run client side.

Business Rule Components

The below components are all the parts that we need to build a business rule.

Scope

The scope of a business rule tells us where we want our rule to be applied. There are 3 options when deciding where you want it to run -

  • Individual Forms - These are only available for Model Driven applications and run client side.
  • All Forms - Again these are only available for Model Driven applications and run client side.
  • Entity - These are applied to a specific table and run server side and are enforced via any application e.g. Canvas app, API or Power Automate Flow.

Conditions

Conditions are essentially triggers that tell our business rule when it should run. Conditions return either true or false and we can decide the next steps separately. For example Condition = true THEN run Action 1 or Condition = false THEN run Action 1

Multiple Conditions

We can add multiple conditions to a business rule. These can be added with an AND operator, where all the conditions must be met. They can also be added with and OR operator, where only one of the conditions must be met.

Actions

The action is what happens when the scope and conditions are both met. There are a number of actions that you can select when creating a bushiness rule, they're all fairly self explanatory, but i've added a little note -

  • Add recommendation - Displays a recommendation to the user
  • Add Lock/Unlock - Sets a field to read only (lock) or editable (unlock)
  • Show an error message - Displays an error message to the user
  • Set field Value - Sets the value of a field
  • Set default field value - Sets the default value of a field
  • Set Business Required - Sets the field to a required field
  • Set Visibility - Hides or Unhides a field

Thats It

And thats it for Business rules, they're a great way to ensure consistency with data in Dataverse. Shortly i'll add a walkthrough on creating a Business rule. So follow me on Twitter for that.

If you want to use Dataverse for free while learning, you can view this guide on setting up a Power Platform developer environment.

Thanks for reading. Any questions or feedback - Twitter, LinkedIn or Email