Practice Lab 6 – Forms

In this lab you will use forms to create and edit records in a data source.

What you will learn

  • How to add screens
  • How to navigate between screens
  • How to use a form to create a record in a data source
  • How to use a form to edit a record in a data source
  • How to delete a record from a data source
  • How to link a form to a gallery

High-level lab steps

  • Create new screens
  • Navigate to a screen when a record is selected in a gallery
  • Navigate between screens
  • Display a record with a form
  • Delete a record
  • Edit a record with a form
  • Create a new record with a form

Prerequisites

  • Must have completed Lab 5: External data

Detailed steps

Exercise 1 – Add screens and navigation

Task 1.1 - Edit the app

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

  2. Make sure you are in the Dev One environment.

  3. Select the Apps tab from the left navigation menu.

  4. Select the Booking Request app, select the Commands (), and select Edit > Edit in new tab.

Task 1.2 - Add screens

  1. In the app authoring menu, select Tree view.

  2. At the top of the Tree view, select + New screen.

    Screenshot of new screen.

  3. Select Blank.

  4. Rename the screen to EditScreen.

  5. At the top of the Tree view, select + New screen.

  6. Select Header and footer.

  7. Rename the screen to DetailScreen.

Task 1.3 - Add navigation

  1. In the Tree view, expand BookingRequestList in the MainScreen.

  2. Select NextArrow in BookingRequestList.

  3. Set the OnSelect property of NextArrow in the formula bar to:

     Collect(colRequests, ThisItem);Navigate(DetailScreen, ScreenTransition.Cover);
    
  4. Select EditScreen.

  5. In the app authoring menu, select Insert (+).

  6. Expand Icons.

  7. Select Back arrow.

  8. Set the OnSelect property of the icon to:

     Back()
    
  9. Rename the icon to BackIconEdit.

  10. In the Tree view, select the icon and select the Commands () and select Copy.

  11. Expand DetailScreen.

  12. Expand ScreenContainer.

  13. Select HeaderContainer and select the Commands () and select Paste and select Paste.

  14. Rename the icon to BackIconDetail.

Exercise 2 – Details screen

Task 2.1 - Add display form

  1. In the app authoring menu, select Tree view.

  2. Expand DetailScreen.

  3. Expand ScreenContainer1.

  4. Select MainContainer1.

  5. In the app authoring menu, select Insert (+).

  6. Expand Input.

  7. Select Display form.

    Screenshot of adding a display form.

  8. In the FormViewer’s properties, select Booking Requests for Data source.

  9. Select 10 selected next to Fields.

    Screenshot of default form fields.

  10. Add or remove the fields so that they are arranged in following order :

    1. Pet Name
    2. Owner Name
    3. Owner Email
    4. Start Date
    5. End Date
    6. Decision
    7. Cost

    Screenshot of sorting the form fields.

  11. Close the Fields pane.

  12. Set the Item property of the form viewer control in the formula bar to:

     BookingRequestList.Selected
    

Task 2.2 - Add label

  1. In the app authoring menu, select Tree view.

  2. Expand DetailScreen.

  3. Expand ScreenContainer1.

  4. Select FooterContainer1.

  5. Select + within the Footer container.

    Screenshot of adding a control to the container.

  6. Select Text label

  7. Set the Text property of the label to:

     BookingRequestList.Selected.'Pet Name'
    

Task 2.3 - Add delete button

  1. In the app authoring menu, select Tree view.

  2. Expand DetailScreen.

  3. Expand ScreenContainer1.

  4. Select FooterContainer1.

  5. In the app authoring menu, select Insert (+).

  6. Select Button.

  7. In the app authoring menu, select Tree view.

  8. Rename the Button to Deletebtn.

  9. Set the Text property of the button to:

     "Delete"
    
  10. Set the OnSelect property of the button to:

     Remove('Booking Requests', BookingRequestList.Selected); Back();
    

Exercise 3 – Edit screen

Task 3.1 - Add Edit form

  1. In the app authoring menu, select Tree view.

  2. Select EditScreen.

  3. In the app authoring menu, select Insert (+).

  4. Select Edit form.

  5. In the Form’s properties, select Booking Requests for Data source.

  6. Select 9 selected next to Fields.

  7. Add or remove the fields so that they are arranged in following order :

    1. Pet Name
    2. Owner Name
    3. Owner Email
    4. Start Date
    5. End Date
    6. Cost
  8. Close the Fields pane.

  9. Set the Item property of the form control to:

     BookingRequestList.Selected
    
  10. In the app authoring menu, select Tree view.

  11. Rename the form to BookingRequestForm.

  12. Set the properties of the form as follows:

    1. X=0
    2. Y=125
    3. Height=500
    4. Width=Parent.Width
    5. Columns=1
    6. Layout=Horizontal

    Screenshot of the configured booking request form.

Task 3.2 - Add submit button

  1. In the app authoring menu, select Tree view.

  2. Select EditScreen.

  3. In the app authoring menu, select Insert (+).

  4. Select Button.

  5. Drag the button below the form.

  6. In the app authoring menu, select Tree view.

  7. Rename the Button to Submitbtn.

  8. Set the Text property of the button to:

     "Submit"
    
  9. Set the OnSelect property of the button to:

     SubmitForm(BookingRequestForm)
    
  10. Select BookingRequestForm.

  11. Set the OnSuccess property of the form to:

     Navigate(MainScreen, ScreenTransition.UnCover)
    

Task 3.3 - Add navigation to the edit screen

  1. In the app authoring menu, select Tree view.

  2. Expand DetailScreen.

  3. Expand ScreenContainer.

  4. Select HeaderContainer.

  5. In the app authoring menu, select Insert (+).

  6. Expand Icons.

  7. Select Edit.

  8. In the app authoring menu, select Tree view.

  9. Rename the icon to EditIcon.

  10. Set the OnSelect property of the icon to:

     Navigate(EditScreen, ScreenTransition.Cover)
    

Task 3.4 - New record

  1. In the app authoring menu, select Tree view.

  2. Select MainScreen.

  3. In the app authoring menu, select Insert (+).

  4. Expand Icons.

  5. Select Add.

  6. In the app authoring menu, select Tree view.

  7. Rename the icon to NewIcon.

  8. Set the properties of the icon as follows:

    1. X=0
    2. Y=0
    3. Height=80
    4. Width=80
    5. Color=Color.White
  9. Set the OnSelect property of the icon to:

     NewForm(BookingRequestForm);Navigate(EditScreen, ScreenTransition.Cover)
    
  10. Select Save in the top-right of the Power Apps Studio.

  11. Select the <- Back button from the top left of the command bar, and select Leave to exit the app.