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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Project table.

  7. Under Schema, select 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. Select Done.

    Referential Restrict relationship.

Task 1.2 – Project-Milestone relationship

  1. In the Project table Relationships, select Project from the 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. Select 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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Project table.

  7. Under Schema, select Relationships.

  8. Select + New relationship and choose 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. Select Done.

    Referential Restrict relationship.

  17. In the Objects pane on the left, select 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. Select 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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Region table.

  7. Select + 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. Select 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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Project Outcome table.

  7. Under Schema, select Relationships.

  8. Select + 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. Select Done.

Task 4.2 – Create new relationship to Outcome

  1. Select + 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. Select 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. Select 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, change the Required drop-down to Business required.

  4. Expand Advanced options and scroll down.

  5. Check the Enable auditing box.

  6. Select Save.

  7. Select the Outcome column.

  8. In the Edit column pane that appears on the right-hand side of the screen, change the Required drop-down to Business required.

  9. Expand Advanced options and scroll down.

  10. Check the Enable auditing box.

  11. Select Save.

Task 4.4 – Mappings

  1. In the Fabrikam Environmental solution, select the Objects page and select All.

  2. Select the ellipsis menu and select Switch to classic.

  3. In the legacy Solution Explorer, expand Entities.

  4. Expand Project.

  5. Select 1:N Relationships.

    One to many relationships in Solution Explorer.

  6. Select the relationship between Project and Project Outcome.

    One to many relationship in Solution Explorer.

  7. Select More Actions and select Edit.

  8. Select Mappings.

    Mappings pane.

  9. Select New.

  10. In the left-hand side, select contoso_projecttitle.

  11. In the right-hand side, select contoso_title.

  12. Select OK.

    New mapping pane.

  13. Select New.

  14. In the left-hand side, select contoso_projectsummary.

  15. In the right-hand side, select contoso_comments.

  16. Select OK.

    Mappings added.

  17. Select Save and Close. Select Publish All Customizations.

  18. Close the Solutions Explorer tab.

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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Resource table.

  7. Select 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. Select 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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Milestone table.

  7. Select 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. Select Save.

Task 5.3 – Publish changes

  1. In the solution, select the Overview page.

    Overview.

  2. Select Publish all customizations.

Task 5.4 – Add connection roles

  1. In the Fabrikam Environmental solution, select the Objects page and select All.

  2. Select + New > More and then select Connection Role.

  3. Enter Contributor for Name.

  4. Select the Only these record types radio button.

  5. Select Resource.

  6. Select the Save icon.

    Add connection role.

  7. Under Matching Connection Roles, select 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. Select the Save and Close icon.

  12. Select the Save and Close icon.

  13. Select Done.

  14. Select + New > More and then select Connection Role.

  15. Enter Advisor for Name.

  16. Select the Only these record types radio button.

  17. Select Resource.

  18. Select the Save icon.

  19. Under Matching Connection Roles, select Add Existing.

  20. Add Contributed to to the selected records by selecting the row using the Select button.

  21. Select Add.

  22. Select the Save and Close icon.

  23. Select 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 the Dev One environment.

  3. Select Solutions.

  4. Open the Fabrikam Environmental solution.

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

  6. Select the Outcome table.

  7. Select + New > 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. Select Save and edit.

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

  15. Select Approver for Field.

  16. Select Contains data for Operator.

  17. Select the green check mark.

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

  18. Select + 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. Select the blue check mark.

    Add calculated column using a relationship.

  21. Select SAVE AND CLOSE.

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

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

  2. Select the Project table.

  3. Select + New > 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. Select Save and edit.

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

  9. Select Project Funding (Project) for Related.

  10. Select the blue check mark.

  11. Select + Add condition.

  12. Choose Status for Field.

  13. Choose Equals for Operator.

  14. Verify Active is selected for Value.

  15. Select the green check mark.

  16. Select + Add aggregation.

  17. Select SUM for Aggregate Function.

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

  19. Select the green check mark.

  20. Select SAVE AND CLOSE.

    Add rollup column.

Task 6.3 – Publish changes

  1. In the solution, select the Overview page.

  2. Select Publish all customizations.

Exercise 7 – Solutions

In this exercise, you will export the solution from the Development environment and import it into the Production 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 Dev One environment.

  3. Select Solutions.

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

  5. Select Solution checker > Run.

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

  7. Select Solution checker > View results.

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

  9. Select the back arrow to return to solutions.

Task 7.2 – Export managed solution

  1. Select the Fabrikam Environmental solution row but do not open it.

  2. Select Export solution.

  3. Select Next.

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

  5. Change the version number to 1.1.11.6

  6. Select Managed for Export as.

  7. Select Export.

  8. The export will be prepared in the background. When the solution is ready, select the Download button.

Task 7.3 – Export unmanaged solution

  1. Select the Fabrikam Environmental solution row but do not open it.

  2. Select Export Solution.

  3. Select Next.

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

  5. Change the version number to 1.1.11.6

  6. Select Unmanaged for Export as.

  7. Select Export.

  8. The export will be prepared in the background. When the solution is ready, select 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 Production 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_6_managed.zip and select Open.

  6. Select Next.

  7. Select Next.

    Wait for connections to be created for the solution.

  8. Both connections should be selected.

  9. Select Next.

  10. Select 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.