A Dive Into Dataverse Business Rules

Microsoft Dataverse rise to prominence comes at a time when businesses are generating and collecting vast amounts of data from various sources, including customer interactions, IoT devices and social media.  This data growth highlighted the need for structured data storage and management solutions.  Started in 2016 as The Common Data Service, the platform was introduced to address many of these trends and provide organizations with a platform for structured data management, application development and automation.  The addition of a business rules layer to Dataverse has further assisted citizen developers and pros alike in the creation of robust Power Platform-driven solutions. This article explores Dataverse business rules and best practices.

Background

Crafting and automating a business process mirrors the artistry of crafting an exquisite dessert within a renowned kitchen.  In this culinary ballet, a dynamic ensemble collaborates harmoniously: kitchen organizers, akin to business analysts and solution architects, curate the culinary direction, while skilled chefs, synonymous with citizen developers and code pros, meticulously prepare the masterpiece.  Behind the scenes, the diligent support staff, and resource suppliers (cloud engineers) ensure resources flow seamlessly to enable the culinary symphony.

Just as a recipe guarantees each dish’s consistent quality, the business world relies on standard operating procedures that define the allowable states and requirements for valid business data.  Enter Microsoft Dataverse and business rules.

Microsoft Dataverse (and the Power Platform) offers the unique ability to guide users through data input, store data seamlessly, navigate data approval based on policies and analyze data for informed business decisions.

Getting the Ingredients Right

Like a kitchen where a missing ingredient alters a dish’s preparation or quantity adjustments reshape its taste, business processes also require valid inputs.  Dataverse’s Business Rules apply a solution to these complexities at the root point – the data table.  Model-Driven Power Apps then inherit these business rules to gracefully adjust user information input. In the realm of culinary arts, altering recipes often involves specific rules.  If a particular ingredient is unavailable, the dish might be removed from the menu.  When eggs are absent, creative alternatives like applesauce and mashed bananas step in for baking.  These scenarios pivot around the concepts of scope (the event’s context) and conditions (specific circumstances).  Dataverse Business rules provide the scaffolding of scope and conditions, harmonizing a user’s input data with the business process blueprint.

Business Rule Scope

Business process rules seamlessly adapt to a chosen scope, applying consistently or selectively when capturing user inputs.  Model-Driven Applications Business rules primarily reside within the Model-Driven application, designed to efficiently create, or modify information across tables.  While Canvas apps present similar actions within edit form objects, they lack support for certain functions like “Show or hide columns,” “Enable or disable columns,” or “Create business recommendations based on business intelligence.”

Creating Business Rules

The Dataverse table editor, accessible at https://make.powerapps.com/ under the tables table tab:

Once a table is selected the Business Rules button will appear in the top-right. Initiating “Add Business Rule” ushers you into the Business Rule Editor:

Selecting Scope

At the top left corner of the Editor, Scope beckons. Tailor the following options to suit your business dynamics:

  • Entity: Table-level scope, wielding influence over all forms and contexts that feature the targeted column that users will interact with to input data.
  • All Forms: Universally applied across all forms, bestowing rule impact whenever users input or modify column data.
  • Specific Form: Granular application to columns within a designated form.

Pro Tips

  • For Canvas app utilization, Microsoft underscores the Entity scope.
  • Employ the “All Forms” scope or a form integral to the business process flow when weaving flows into the business process (a subject we’ll delve into shortly).

Business Rule Conditions

Conditions determine precisely which columns should figure into the business process – this is Dataverse selecting a specific ingredient for our recipe.  In the Dataverse realm, conditions provide versatility, encompassing comparisons like:

  • equal/not equal
  • less than/less than or equal to
  • greater than/greater than or equal to
  • contains/doesn’t contain
  • begins with/doesn’t begin with
  • ends with/doesn’t end with

and even check for the presence of required data.  These operators that breathe life into your conditions and can be specified as follows:

  1. Designer Window and Properties Tab: Within the designer window, navigate to the properties tab associated with the chosen condition.
  2. Field Selection: Handpick the field (column) that your rule should embrace. Select the fitting operator and the corresponding value to ignite the rule’s action.
  3. Operator and Value Configuration: Configure the operator (such as equals, greater than, less than, and others) that crystallizes your condition’s logic. Articulate the anticipated value against which the comparison shall be measured. This can be applied to a value that you can enter for validation or this can be a comparison to the value in another field(column).

At this juncture, we’ve elegantly defined both the scenarios in which the rule will be in place (scope) and the spotlight on which this rule shall shine or be enacted upon (condition).

Pro Tip

For those who seek a richer selection of conditions and/or validation requirements, here’s your guide:

  1. Properties Tab: Make your way to the Properties tab.
  2. New Rule Creation: Opt for the “New” option, unleashing the power to craft a fresh rule.
  3. Detail Crafting: Carve out the particulars for this new rule, homing in on your distinct needs.
  4. Rule Logic Unveiled: In the column named “Rule Logic,” you can connect this new condition with the previous one using an AND (both conditions must be true) or an OR (either condition can be true).

Setting a Rule

After defining the rule’s scope (context) and its applicable condition, let’s focus on the allowed actions.  Dataverse offers various actions if our business rule isn’t met, presented as action objects:

  • Recommendation
    If the condition is met, display a guiding text message to prompt user input adjustment or update another column based on provided info. Actions can be put inside of the recommendation to make additional fields so the recommendation can be made and the recommended action can take place from this one step.
  • Lock/Unlock
    When the condition is met, toggle the availability of a field, useful for customizing data entry based on project types.
  • Show Error Message
    Like an unavailable ingredient in the kitchen, prevent more input until the column is modified, ensuring valid information for processing.
  • Set Field Value
    Change another field’s value based on the condition, like marking “yes” when a certain input threshold is surpassed.
  • Set Default Value
    Revert another field to its default value when the condition is met, streamlining data entry.
  • Set Business Required
    Make a field mandatory based on the condition, adapting forms for specific project types.
  • Set Visibility
    Modify field visibility based on the condition.

These actions guide how user inputs are handled when they don’t meet expectations, enhancing clarity and ensuring necessary steps are taken.  Implement these rules for both met and unmet conditions and stack multiple actions together within a rule.  Warning: to edit a current business rule you will need to deactivate it existing rule before modifying it.

To create a rule:

  • Components Tab: Open the Components tab to access all available actions.
  • Drag and Drop: Drag actions to the plus sign next to a check mark for met conditions, or next to an x for unmet conditions.
  • Action Details: Edit action specifics in the Properties tab on the right side of the designer view.

Cover Both Cases
Set actions for both met and unmet conditions for better insight and testing. You can reset a field’s value to its original state or unlock a field even if it’s already unlocked. Remember, Microsoft recommends covering both cases for a clearer rule and effective testing of actions.

Review Business Rule Steps
After adding all the necessary steps to your business rule, you can utilize the Business Rules Text View. This recently introduced feature, included in the Power Platform’s Coplot capabilities, provides a user-friendly explanation of the rule in plain language. It helps ensure that the code and actions align with the company’s established policy.

Validate Your Business Rule

Once you’ve added and configured all the required steps within your business rule, it’s essential to validate your work. Click on the “Validate” button located in the top-right corner. This step ensures that your business rule is functioning as intended and adheres to the set criteria.

Activate Your Rule
Once your rule is validated, the “Activate” button will appear in the top-right corner. Use this button to turn the rule on, making it effective for your processes.

Let’s Bake a Cake

Let’s consider a practical scenario involving a business rule to determine if a project’s cost requires executive approval:

  • Table Setup
    A table is created with three columns: “Title,” “Project Cost,” and “Executive Approval Needed.”

Business Rule Context
Establish a business rule that applies across all instances of the form. The condition is triggered when the “Project Cost” is equal to or exceeds $10,000.

  • Actions for Condition Met
    Add actions to respond when the condition is met:
    • A recommendation message is generated, stating: “Given the request’s cost exceeding $10,000, executive approval is necessary.”
    • A sub-action updates the “Executive Approval Needed” field to “Yes.”
    • Another sub-action locks the “Executive Approval Needed” column to prevent further changes.
  • Counter Actions for Condition Not Met
    Implement counter actions for when the condition isn’t satisfied by resetting the “Executive Approval Needed” field to its default value of “No.”

Business Rule in Action in a Model-driven App

Apply this business rule within a model-driven app:

This approach ensures that projects with costs equal to or surpassing $10,000 automatically trigger the need for executive approval, while projects below this threshold maintain the default “No” status for executive approval.

Business Process Flows

Much like their role in model-driven apps, forms, and canvas apps; Dataverse Business Process Flow rules can also be effectively employed within business process flows.  Business process flows function as guided forms, leading users through each step.

Within these flows, developers seamlessly integrate business rules.  The main distinction lies in the scope setting – the business rule needs to be applied at the form or all levels of the flow.  Once this scope is set, additional options become available, such as the ability to choose “Value with Stage” in the form’s condition.  This choice enables the rule’s application in a specific stage of the flow, or alternatively, allows the rule to affect selected fields across all stages of the process.

Time for Dessert

These culinary-inspired Dataverse Business Rules harmonize data management, mirroring a chef’s attention to detail, and elevate user experiences within model-driven applications.  Chefs, or developers, define the scope, specifying where the rules apply, while conditions act as the recipe’s key instructions.  Validation serves as the taste test, ensuring the rule’s success, before the “Activate” button is pressed, making the rule ready to serve.

Just as a renowned kitchen produces consistent and exceptional dishes, these rules promote streamlined and efficient workflows, turning business processes into a culinary delight for users while controlling consistency and standardization, enhancing the quality of the data input, and ensuring compliance and governance of company policies.

Interested In Our Dataverse Services?

"*" indicates required fields

Want brilliance sent straight to your inbox?