Navigate the model-driven app

Completed

An important aspect of model-driven apps is the data model and how the different tables relate to each other. This section reviews how those relationships help simplify data navigation and allow users to view:

  • Accidents that an employee has been involved in.

  • Accidents that have occurred in a particular location.

  • A list of all accidents.

Finding the related records for the preceding information is possible because of the table relationships that you previously built during your data modeling module. In this unit, we'll learn how to find related records by using the Related view in model-driven apps.

Create new records by using model-driven apps

To observe how the app functions, start by creating new records with it:

  1. Under Solutions, find and select Accident Tracking then select the Accident Tracking Application model-driven app. Select Play from the command bar menu.

  2. Select Employees from under Accident Tracking and then select + New in the command bar.

    This step will direct you to the main form that you modified in the previous unit. In the next steps, you'll create two new employees.

  3. Create the first new employee with the following information:

    • EmployeeName - Renata Hall

    • EmployeeDOB - 8/15/1996 (as you enter the date, select inside of the field to manually input the date vs. selecting via the calendar)

    • EmployeeEmail - rhall@contoso.com

  4. Notice that you must create the record before uploading an image. Select Save and then add a new employee picture file by selecting Choose File.

    EmployeePicture - Choose any picture, then select Save & Close

  5. Create another new employee with the following information:

    • EmployeeName - Nathan Rigby

    • EmployeeDOB - 7/15/1999

    • EmployeeEmail - nrigby@contoso.com

  6. Select Save and then add a new employee picture file.

    EmployeePicture - Choose any picture.

  7. Create a new location. Select Location under Accident Tracking, select + New, and then add the following information:

    • LocationName - Contoso East

    • LocationCountry - USA

  8. Select Save & Close.

  9. Create a new type of accident. Select Type of Accident, select + New, and then add the following information:

    • AccidentName - Head Trauma

    • AccidentSeverity - 5

  10. Select Save & Close.

  11. Create a new accident. Select Accidents from the app, select + New, and then add the following information:

    • LocationId - From the dropdown menu, select Contoso East.

      Tip

      If you press the Enter key while on the dropdown menu, you'll see the location table with names, other than only their IDs. Same with the other entry fields. With the input field blank, selecting the Enter key shows a list of available options.

    • AccidentTypeId - From the dropdown menu, select Head Trauma.

    • AccidentDate - 10/1/2022

    • AccidentDescription - Two employees fell causing severe trauma.

  12. Save the record. Notice that once you save, under Involved Employees, you'll see a view of our subgrid EmployeeTable. Next select Add Existing Employee... to add some employees to this incident.

    Screenshot of the New accident form with highlights on the four entry fields and the save button.

  13. In the Lookup Records popup (remember you can Enter in the Search field to show all records), select the Employee IDs that correspond with Renata Hall and Nathan Rigby. Though we're not going to do it in this exercise, it's possible to modify this Lookup Records view to incorporate the actual employee names. Then select Add to add these employees to the event. If you select the wrong employees, you can select the More commands ellipsis from the top right of the Involved Employees table and choose the Remove option for selected employees.

  14. You should now see the two employees listed under Involved Employees in your entered accident. Select Save & Close to complete the entry.

In this section, you'll learn how to navigate in the app to find information with related data. Previously, you created relationships between your tables to help make this process easier.

You can create a many-to-many relationship between your EmployeeTable and AccidentTable because multiple employees can be involved in multiple accidents. In this scenario, you want to review the accidents that Renata Hall has been involved in.

  1. Go to Employees from the model-driven app.

  2. Select the record for Renata Hall.

  3. Select Related > AccidentTables. You'll be directed to a view that lists the accidents that Renata Hall has been involved in.

  4. Select any record to bring up the accident details.

You can also complete this related action from the Locations > Related > AccidentTables to view all accidents that have occurred in that location. The reason is because of the one-to-many relationship that you built in a previous module between LocationTable and AccidentTable. By using the same concept, you can use the related action to view the accidents that belong to a particular accident type. These actions are standard from model-driven apps if relationships exist between the tables.

Now that you see how easy it's to navigate from table to table inside of your app, let's approach how to modify a view inside of your app.