Exercise - Create a business rule

Completed

In this exercise, you'll use the Passenger entity set up in this learning path. If you didn't create the Cruises and Passenger entity as a part of this learning path, complete the steps in Exercise - Create two tables and relate them by using a one-to-many relationship to complete these exercises.

  1. Sign in to Power Apps maker portal.

  2. Open Tables.

  3. Select the Passengers table.

  4. Select + New Column (formerly called fields), enter Age in the Display Name field. In the Data Type drop-down list, select Whole Number, and then select Save to add the new column.

    Screenshot of Field Properties window with values entered.

  5. In the + New Column window, add another column. Enter ID Required in the Display Name field, select Choice > Yes/No in the Data Type drop-down list.

  6. Select Save to save the column.

  7. Select the Business rules and then select + New business rule on the menu. Be patient; it will take time to load the business rule designer.

  8. In the main design area, select Condition. This selection opens a panel to let you set the condition for the business rule.

    Screenshot of Condition selected in the main design area.

  9. Add the following information into the fields on the Condition panel.

    Condition panel field Value
    Entity Passengers
    Source Entity
    Field Age
    Operator Is Greater Than
    Type Value
    Value 18

    Screenshot of Properties fields and values entered.

    Screenshot of Properties with Apply button.

  10. Select the Apply button at the bottom of the panel.

    Now, you'll define action for the Yes or No branch, meaning that you'll indicate what you want to happen if the age of the person who is entered is 18 or under or over 18.

  11. Select the Components tab and then select the Set Field Value new action and drag it to the right-hand side of the Conditions panel.

    Screenshot of Components tab with Set Field Value action.

  12. On the Set Field Value component, enter Passenger Over Age 18 in the Display Name field to indicate that the passenger's age is greater than 1. In the Entity field, enter Passengers. Select ID Required in the Field drop-down menu, and then select Yes in the Value drop-down menu, and select Apply.

    Screenshot of the Set Field Value with properties entered.

    Screenshot of Set Field Value with values entered and Apply button.

  13. Select the Set Field Value component and drag it under the Condition, as shown in the following screenshot. Then, on the Components panel on the right, in the new Set Field Value component, enter Passenger Age 18 or Under in the Display Name field, and then set the Value option to No.

    Screenshot of Set Field Value component added under the Condition.

    Screenshot of the Properties with values entered and Apply button.

  14. Now that the rule is set, notice that the business rule formula is shown in the window.

    Screenshot of the Business Rule Formula Window.

  15. If you receive no errors, select Validate and then select Save.

    Screenshot of Validate and Save Rule Buttons.

  16. Select the arrow next to Passengers: New business rule in the top left of the screen. Enter a name in the Business rule name field and a description for the business rule in the Description field. Select Save.

    Screenshot of arrow next to Passengers: New business rule and Save rule button.

  17. Close the browser window. Return to browser, select Tables > Passengers, and then select the Business rules. In the Currently creating a new business rule window, select the Done button.

  18. The business rule that you created will appear on the list as Deactivated. To activate it, you'll need to reset the ID Required field value. To start the process, select the new business rule that you created.

    Screenshot of business rule with status Deactivated.

  19. Select the Activate button on the menu bar at the top right. This will cause a Process Activate Confirmation dialog box to appear. Confirm activation by selecting the Activate button at the bottom of the dialog box.

    Screenshot of the Activate button and the Process Activate Confirmation button.

  20. Close the Browser tab and select Tables > Passengers > Business rules tab, which shows that the business rule that you created now has the status of Activated.

Congratulations, you've created a business rule. You can test it by selecting the Data tab and entering data by using Excel.