Practice Lab 1.6 – Relationships

Scenario

You are a Power Platform functional consultant and have been assigned to the Fabrikam project for the next stage of the project.

In this practice lab, you will be modifying the properties of existing relationships, creating new relationships, and creating rollup columns.

You will then export your customizations from the solution and import them into another environment.

Exercise 1 – Change relationship behaviors

In this exercise, you will be modifying the cascade relationships for the project table. The Region to Project relationship will be changed to referential, restricted and the Project to Milestone relationship will be changed to custom.

Task 1.1 – Region-Project relationship

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Project table.

  7. Under Schema, click on Relationships.

  8. Scroll down and select the Region relationship.

  9. In the Many-to-one pane that appears on the right-hand side of the screen, expand Advanced options.

  10. Change the Delete drop-down to Restrict.

  11. Click Done.

    Referential Restrict relationship.

Task 1.2 – Project-Milestone relationship

  1. Select the Milestone relationship in the Project table. Note that this relationship uses Project as the Display name and contoso_project_milestone as the Name.

  2. In the One-to-many pane that appears on the right-hand side of the screen, expand Advanced options.

  3. Change the Type of behavior drop-down to Custom.

  4. Change the Delete drop-down to Restrict.

  5. Change the Assign drop-down to Cascade Active.

  6. Change the Share drop-down to Cascade User-Owned.

  7. Change the Unshare drop-down to Cascade User-Owned.

  8. Click Done.

    Cascade relationship.

Exercise 2 – Add new relationship

In this exercise, you will create a new relationship between the Resource and Project tables to create a lookup for the Lead Resource on the Project.

Task 2.1 – Create new Project Lead relationship

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Project table.

  7. Under Schema, click on Relationships.

  8. Click + New relationship and then select Many-to-one.

  9. In the Many-to-one pane that appears on the right-hand side of the screen, select Resource in the Related (One) drop-down.

  10. Enter Project Lead for Lookup column display name.

  11. Enter projectleadresourceid for Lookup column name.

  12. Expand General.

  13. Enter resource_project_projectlead for Relationship name.

  14. Expand Advanced options.

  15. Change the Delete drop-down to Restrict.

  16. Click Done.

    Referential Restrict relationship.

  17. In the Objects pane on the left, click Columns for the Project table.

  18. Select the Project Lead column.

  19. In the Edit column pane that appears on the right-hand side of the screen, expand Advanced options and scroll down.

  20. Check the Enable auditing box.

  21. Click Save.

Exercise 3 – Hierarchical relationship

In this exercise, you will create a new hierarchical relationship on the region table.

Task 3.1 – Create new hierarchical relationship

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Region table.

  7. Click + New, and then select Relationship and then select + One-to-many.

  8. In the One-to-many pane that appears on the right-hand side of the screen, select Region in the Related (Many) drop-down.

  9. Enter Parent Region for Lookup column display name.

  10. Enter parentregionid for Lookup column name.

  11. Check the Hierarchical box.

  12. Expand General.

  13. Enter parentregion_region for Relationship name.

  14. Expand Advanced options.

  15. Change the Delete drop-down to Restrict.

  16. Click Done.

    Hierarchical relationship.

Exercise 4 – Project Outcome relationships

In this exercise, you will create two many-to-one relationships for the Project Outcome table to the Project and Outcome tables. These relationships will be used to replace the many-to-many relationship between the Project and Outcome tables.

Task 4.1 – Create new relationship to Project

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Project Outcome table.

  7. Under Schema, click on Relationships.

  8. Click + New relationship and then select Many-to-one.

  9. In the Many-to-one pane that appears on the right-hand side of the screen, select Project in the Related (One) drop-down.

  10. Enter Project for Lookup column display name.

  11. Enter projectid for Lookup column name.

  12. Expand General.

  13. Enter project_projectoutcome for Relationship name.

  14. Expand Advanced options.

  15. Change the Type of behavior drop-down to Parental.

  16. Click Done.

Task 4.2 – Create new relationship to Outcome

  1. Click + New relationship and then select Many-to-one.

  2. In the Many-to-one pane that appears on the right-hand side of the screen, select Outcome in the Related (One) drop-down.

  3. Enter Outcome for Lookup column display name.

  4. Enter outcomeid for Lookup column name.

  5. Expand General.

  6. Enter outcome_projectoutcome for Relationship name.

  7. Expand Advanced options.

  8. Change the Type of behavior drop-down to Parental.

  9. Click Done.

    NOTE: An error will be shown saying that you cannot create another parental relation with the contoso_outcome table.

  10. Change the Type of behavior drop-down to Referential.

  11. Change the Delete drop-down to Restrict.

  12. Click Done.

Task 4.3 – Set required and enable auditing on new lookup columns

  1. In the Objects pane on the left, select Columns for the Project Outcome table.

  2. Select the Project column.

  3. In the Edit column pane that appears on the right-hand side of the screen, expand Advanced options and scroll down.

  4. Change the Required drop-down to Business required.

  5. Check the Enable auditing box.

  6. Click Save.

  7. Select the Outcome column.

  8. In the Edit column pane that appears on the right-hand side of the screen, expand Advanced options and scroll down.

  9. Change the Required drop-down to Business required.

  10. Check the Enable auditing box.

  11. Click Save.

Exercise 5 – Connections

In this exercise, you will enable connections for the resource and milestone tables.

Task 5.1 – Enable connections on Resource

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Resource table.

  7. Click on Properties.

  8. In the Edit table pane that appears on the right-hand side of the screen, expand Advanced options and scroll down.

  9. Check the Can have connections box.

  10. Click Save.

Task 5.2 – Enable connections on Milestone

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Milestone table.

  7. Click on Properties.

  8. In the Edit table pane that appears on the right-hand side of the screen, expand Advanced options and scroll down.

  9. Check the Can have connections box.

  10. Click Save.

Task 5.3 – Publish changes

  1. In the solution select the Overview page.

    Overview.

  2. Click on Publish all customizations.

Task 5.4 – Add connection roles

  1. Within the solution, select the Objects page and select All.

  2. Click + New, and then select More and then select Connection Role.

  3. Enter Contributor for Name.

  4. Select the Only these record types radio button.

  5. Select Resource.

  6. Click the Save icon.

    Add connection role.

  7. Under Matching connection roles, click New.

    NOTE: You may need to disable the pop-up blocker in your browser.

  8. Enter Contributed to for Name.

  9. Select the Only these record types radio button.

  10. Select Milestone.

  11. Click the Save and Close icon.

  12. Click the Save and Close icon.

  13. Click Done.

  14. Click + New, and then select More and then select Connection Role.

  15. Enter Advisor for Name.

  16. Select the Only these record types radio button.

  17. Select Resource.

  18. Click the Save icon.

  19. Under Matching connection roles, click Add Existing.

  20. Check Contributed to and click Select.

  21. Click Add.

  22. Click the Save and Close icon.

  23. Click Done.

Exercise 6 – Calculated and rollup columns

In this exercise, you will use relationships to create calculated and rollup fields. The calculated column will add the email address for the approver to the outcome table. The rollup column will sum the funding values of projects.

Task 6.1 – Calculated column for a many-to-one relationship

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in your Practice environment.

  3. Select Solutions.

  4. Click to open the Fabrikam Environmental solution.

  5. In the Objects pane on the left, click and expand Tables.

  6. Select the Outcome table.

  7. Click + New, and then select Column.

  8. Enter Approver Email for Display Name.

  9. Enter Email address for approver for Description.

  10. Select Single line of text in the Data type drop-down.

  11. Select Text in the Format drop-down.

  12. Change the Behavior drop-down to Calculated.

  13. Click on Save and edit.

  14. When the new browser window opens, click + Add condition.

  15. Select Approver for Field.

  16. Select Contains data for Operator.

  17. Click the green check mark.

    NOTE: You may need to resize the window to see the check marks.

  18. Click + Add Action.

  19. Enter the following formula:

    contoso_approveruserid.internalemailaddress

    NOTE: You can use intellisense to type and select the elements in the formula.

  20. Click the blue check mark.

    Add calculated column using a relationship.

  21. Click SAVE AND CLOSE.

Task 6.2 – Rollup column for the project one-to-many relationship

  1. In the Objects pane on the left, click and expand Tables.

  2. Select the Project table.

  3. Click + New, and then select Column.

  4. Enter Total Project Funding for Display Name.

  5. Select Currency in the Data type drop-down.

  6. Change the Behavior drop-down to Rollup.

  7. Click on Save and edit.

  8. When the new browser window opens, click + Add related entity.

  9. Select Project Funding (Project) for Related.

  10. Click the blue check mark.

  11. Click + Add condition.

  12. Select Status for Field.

  13. Select Equals for Operator.

  14. Verify Active is selected for Value.

  15. Click the green check mark.

  16. Click + Add aggregation.

  17. Select SUM for Aggregate Function.

  18. Select (Project Funding) Funding amount for Aggregate Related Entity Field.

  19. Click the green check mark.

  20. Click SAVE AND CLOSE.

    Add rollup column.

Task 6.3 – Publish changes

  1. In the solution select the Overview page.

  2. Click on Publish all customizations.

Exercise 7 – Solutions

In this exercise, you will export the solution from the Practice environment and import it into the MOD Administrator’s environment.

Task 7.1 – Solution checker

  1. Navigate to the Power Apps Maker portal https://make.powerapps.com.

  2. Make sure you are in the Practice environment.

  3. Select Solutions.

  4. Select the Fabrikam Environmental solution but do not open it.

  5. Select the caret to the right of Solution checker and then select Run.

  6. Wait a few minutes for the checker to complete.

  7. Select the caret to the right of Solution checker and then select View results.

  8. You should see several warnings for the canvas app in the solution.

  9. Click the back arrow to return to solutions.

Task 7.2 – Export managed solution

  1. Select the Fabrikam Environmental solution.

  2. Select Export Solution.

  3. Click Next.

  4. The version number should have been incremented to 1.1.11.4.

  5. Select Managed for Export As.

  6. Click Export.

  7. The export will be prepared in the background, when the solution is ready click the Download button.

Task 7.3 – Export unmanaged solution

  1. Select the Fabrikam Environmental solution.

  2. Select Export Solution.

  3. Click Next.

  4. The version number should have been incremented to 1.1.11.5.

  5. Select Unmanaged for Export As.

  6. Click Export.

  7. The export will be prepared in the background, when the solution is ready click the Download button.

Task 7.4 – Import managed solution

  1. Switch environments by using the Environment Selector in the upper right corner of the Maker portal.

  2. Select the MOD Administrator’s Environment environment from the list.

  3. Select Solutions.

  4. Select Import solution.

  5. Select Browse, change to the Downloads folder and select FabrikamEnvironmental_1_1_11_4_managed.zip and select Open.

  6. Click Next.

  7. Click Next.

  8. You need to create connections for the solution.

  9. For the Approvals connection click Select a connection and then + New connection.

  10. A new tab will open in the browser. Click Create.

  11. Switch back to the tab where you are importing the solution and click Refresh.

  12. For the Microsoft Dataverse connection click Select a connection and then + New connection.

  13. A new tab will open in the browser. Click Create. If prompted, sign in with your Microsoft 365 credentials.

  14. Switch back to the tab where you are importing the solution and click Refresh.

  15. Both connections should be selected.

  16. Click Import. The solution will import in the background.

Challenge (Optional)

Under Processes, examine the classic workflow, Project Funding Name, and create a new workflow to set the Title column on the Project Outcome table, when a new record is created or when a project or an outcome lookup column is changed.