NOTE

Effective November 2020:

  • Common Data Service has been renamed to Microsoft Dataverse. Learn more
  • Some terminology in Microsoft Dataverse has been updated. For example, entity is now table and field is now column. Learn more

Lab 03.1: Create apps in Teams

Scenario

It is not uncommon for organizations to accumulate unused computer peripherals, power cords and other electronics. Your organization is taking steps to reuse existing devices and computer peripherals before ordering new equipment.

You are asked to create an application where users can post devices they no longer need and browse through what their colleagues posted.

Requirements

1) Application must use Dataverse for Teams. 2) Users should be able to create new items, edit items they created and see items created by other users. 3) Items should be removed from the list if they are no longer available. 4) Allow users to reserve an item. 5) Allow user to mark item for pick up. 6) If item is reserved, only reserved user should be able to mark item picked up. 7) Users should be able to search items.

What you will learn

1) How to create an application using Dataverse for Teams. 2) How to publish application. 3) How to give other users permission to your application.

Detailed steps

Exercise 1: Get started with Microsoft Dataverse for Teams

In this exercise, you will create a new team and install Power Apps for Teams.

Task 1: Create team

In this task you will create a new team

  1. Navigate to Microsoft Teams.
  2. Select Teams, click Join or create a team and click Create Team.

A screenshot with a box around the teams button on the left side of the window and an arrow pointing to the create team button

  1. Select From scratch.
  2. Select Public.
  3. Enter Green for Team name and click Create.

A screenshot with the word green in the team name field

  1. Click Skip on Add members to Green screen.
  2. You should now have a new team named Green.

A screenshot of the microsoft teams page with your new team named green now under your teams

  1. Do not navigate away from this page.

Task 2: Install Power Apps

In this task you will install Power Apps for Teams.

  1. Click on the … More added apps, search for power apps and select Power Apps.

A Screenshot with an arrow pointing to the ellipsis icon for more added apps on the left side of the page and a box around power apps button

  1. Click Add.

  2. Right click on the Power Apps tab and select Pin.

A Screenshot with an arrow pointing to the power apps icon and a box around the pin button

Exercise 2: Create application

In this exercise, you will provision Dataverse for Teams by creating an application and you will also create a Dataverse table with columns.

Task 1: Create application

In this task, you will provision Dataverse for Teams by creating an application.

  1. Navigate to Microsoft Teams.

  2. Select Power Apps and click Start now.

A screenshot of the power apps for teams home page

  1. Select the Green team you created and click Create.
  2. Wait until provisioning is complete.
  3. Click New > App.
  4. Enter Upcycle for App name and click Save.
  5. Do not navigate away from this page.

Task 2: Create table

In this task, you will create a table and columns.

  1. Click With data and select Create new table.

A screenshot with data option selected and cursor pointing to the create new table link from the select a data source prompt

  1. Enter Gadget for Table name and click Create.
  2. Click + New column.
  3. Enter Description for Display name, select Text for Data type (displayed as Single line of text), and click to expand the Advanced options section.

A screenshot with the cursor pointing to the advanced options link

  1. Change the Maximum character count to 500 and click Save.
  2. Click + New column again.
  3. Enter Availability for Name, select Choice for Type, and click + New choice under Sync this choice with dropdown box. That will open a window to create a global choice to sync with.
  4. Enter Availability for Display name.
  5. Enter Available for the first choice and click + New choice.
  6. Enter Reserved for the second choice and click + New choice.
  7. Enter Picked up for the third choice and click Save.

A screenshot of the new global choice with 3 choice values entered

  1. Select Availability in Sync this choice with.
  2. Select Available for Default choice and click Save.

A screenshot of a new choice column with global choice to sync with selected

  1. Your table screen should now look like the image below. A screenshot of the new Gadget table with Name, Description, Availability columns in a grid layout
  2. Close the table editor by clicking Close button.
  3. Do not navigate away from this page.

Task 3: Add columns

In this task, you will add new columns to the table.

  1. Select the Home tab and click See more.

A screenshot of power apps in teams screen with Home tab selected and the cursor pointing to the see more button in the recent apps window of the home page of power apps

  1. Click to open the Gadget table.
  2. Click + New > Column menu.
  3. Enter Location for Display name, select Text for Data type (displayed as Single line of text), select Business required for Required and click Save.

A screenshot of the add column window with the relevant text in each field

  1. Click + New > Column.
  2. Enter Photo for Display name, select File > Image for Data type, check the Primary image checkbox and click Save.

A screenshot of the add column window with the relevant text in each field

  1. Click + New > Column.
  2. Enter Reserved by for Display name, select Lookup for Data type, select User for Related table and click Save.

A screenshot of the add column window with the relevant text in each field

Task 4: Edit the application

In this task, you will edit the application by filters for gadgets that are available and edit the form.

  1. Select the Home tab and click to open the Upcycle application you created.
  2. Select Screen1. If the screen already contains the form, move to the next step, otherwise click With data and select Gadgets table under Current environment. That will create the screen elements including the form.
  3. Make sure RightContainer1 is expanded and select the EditForm1 control from tree view.

A screenshot with a border around the edit form button under screen 1

  1. Go to the Properties pane and click Edit fields

A Screenshot with an arrow pointing to the edit fields button

  1. Click on the + Add field button.
  2. If any of the fields below does not exist on the EditForm control, click on the + Add field butto, select the missing field and click Add.
    • Name
    • Description
    • Availability
    • Location
    • Reserved by
    • Photo

A screenshot of the add field window

  1. Remove any extra fields and close the Fields pane. Your form should only have Name, Description, Availability, Location, Reserved By and Photo columns.
  2. Change Columns for Snap to columns to 1.

A screenshot with a border around the columns field and the value of 1 in the field itself

  1. Select the Photo inside the canvas and change Width to 400.

A screenshot of the photo selected inside the canvas and a border around the size field changed to 400 in the properties pane

  1. Expand the form and select the Reserved by data card.

A screenshot of a border around reserved by data card selected under edit form 1

  1. Go to the Properties pane, select the Advanced tab and click Unlock.

A Screenshot with an arrow pointing to the lock icon under the advanced tab

  1. Search for display and change the DisplayMode value to DisplayMode.View.

A screenshot with a border around the display mode field

  1. Select the Browse gallery under LeftContainer in the treeview.
  2. Select Items on the formula bar and replace the value with formula below. This formula will filter the gadgets to show only the available gadgets

    Filter(Gadgets, Availability <> [@Availability].'Picked up')

Filter data - screenshot

  1. Select the Image inside the gallery.

A Screenshot with an arrow pointing to image 1 inside the gallery

  1. Go to the formula bar and varify that the value of the Image is set to the formula below.

ThisItem.Photo

  1. Select the Data tab (database icon) in the left navigation, click on the …More actions button of the Gadgets table and select Refresh.

A Screenshot with an arrow pointing to the ellipsis icon for more actions and a border around the refresh button

  1. Click Save and wait for the app to be saved.
  2. Click Preview the app.
  3. Click + New record.

A screenshot of a border around the new record button

  1. Fill out the form and click Tap or click to add a picture.

A Screenshot with an arrow pointing to the tap or click to add a picture button

  1. Provide your own photo or select one from the lab resources folder.
  2. Click Save.

A Screenshot with an arrow pointing to the tick icon to save

  1. Add few more items.
  2. Your app should now look like the image below. Close the preview.

A screenshot of the running app with an arrow pointing to the cross icon to close the preview

  1. Click X to close the app.

Task 5: Update Dataverse rows

In this task, you will add buttons that will let users reserve and/or pick up item, you will also update the rows in Dataverse as reserved or picked up.

  1. Select App from the Tree view and set the OnStart property to the formula below. This formula will create a variable named CurrentUser and set its value to the first user that matches the logged in user’s email.

Set(CurrentUser, First(Filter(Users, 'Primary Email' = User().Email)))

A screenshot with a border around app selected in the screens tab on the left and another border around the formula bar with the relevant command typed in

  1. Select App, select ellipsis and select Run OnStart.
  2. Select the RightContainer.

A screenshot with a border around the RightContainer1 element selected

  1. Click on the + Insert button and select Button.

A Screenshot with an arrow pointing to the plus icon to insert and a border around the button option

  1. Select the Tree view, double click on the button you just added and rename it Reserve Button.

A screenshot with the text "Reserve Button" highlighted as the new name for the button you added

  1. Set the Text value of the Reserve Button to Reserve.
  2. Move the Reserve Button and place it next to the Image.

A screenshot of the Reserve button selected and moved next to the image on the right hand side

  1. Set the DisplayMode value of the Reserve Button to the formula below. This formula will disable the button if the selected item is not available.

If(BrowseGallery1.Selected.Availability = [@Availability].Available, DisplayMode.Edit, DisplayMode.Disabled)

  1. Set the OnSelect value of the Reserve Button to the formula below. This formula will update the selected record by setting the reserved by value to the current user and the availability value to reserved.

Patch(Gadgets, BrowseGallery1.Selected, {Availability: [@Availability].Reserved, 'Reserved by': CurrentUser})

  1. Set the Visible value of the Reserve Button to the formula below. This formula will hide the button if the user is creating a new record.

If(EditForm1.Mode = FormMode.View, true, false)

  1. Select the RightContainer again.
  2. Click on the + Insert button and select Button again.
  3. Select the Tree view, double click on the button you just added and rename it Picked Up Button.

A screenshot with the text "Picked Up Button" highlighted as the name new for button you added

  1. Set the Text value of the Reserve Button to Picked up.
  2. Adjust the width and move the Picked Up Button and place it to the right of the Reserve Button.

A screenshot showing the Picked Up button selected and moved to the right of the Reserve button

  1. Set the DisplayMode value of the Picked Up Button to the formula below. This formula will disable the button if the selected item is reserved and the reserved by user is not the current user.

If(BrowseGallery1.Selected.Availability = [@Availability].Reserved And BrowseGallery1.Selected.'Reserved by'.'Primary Email' <> CurrentUser.'Primary Email', DisplayMode.Disabled, DisplayMode.Edit)

  1. Set the OnSelect value of the Picked Up Button to the formula below. This formula will update the selected record by setting the reserved by value to the current user and the availability value to picked up. The second formula will select the first item of the gallery.

Patch(Gadgets, BrowseGallery1.Selected, {Availability: [@Availability].'Picked up', 'Reserved by': CurrentUser});Select(BrowseGallery1,1)

  1. Set the Visible value of the Picked Up Button to the formula below. This formula will hide the button if the user is creating a new record.

If(EditForm1.Mode = FormMode.View, true, false)

  1. Click Save to save your changes.
  2. Do not navigate away from this page.

In this task, you will add search capability to your application.

  1. Select the RightContainer.
  2. Click on the + Insert menu, select Icons and then select + Add.
  3. Place the icon above the form.

A screenshot of the plus icon selected

  1. Select the icon, go to the Properties and select Search for Icon.

A screenshot with a border around the Search option selected as the icon

  1. Click on the + Insert menu and select Text box.
  2. Select the Tree view.
  3. Select the text box you just added and rename it Search box.

A screenshot of the words "Search Box" highlighted as the new name for the text box you added

  1. Place the Search Box to the right of the icon.

A screenshot of the Search Box placed to the right of the icon

  1. Select the Search Box and set OnChange value to the formula below. This formula will reset the gallery.

Reset(BrowseGallery1)

  1. Select the BrowseGallery under LeftContainer1 and change the Items formula to the formula below. The formula is incomplete, we will complete it in the next step.

Filter(Search(Gadgets, 'Search Box'.Value, ), Availability <> 'Availability (Gadgets)'.'Picked up')

  1. Place your cursor after ‘Search Box’.Value and type name. You should see a suggestion with crxxx_name, select the suggested column.

A screenshot with a border around the words "crefe4_name"

  1. Add comma after the name column you just selected and type description and select the suggested column again.

A screenshot with a border around the worlds "crfe4_description"

  1. Your formula should now look like the image below. This formula will search the name and description columns of the gadgets table for whatever the user types in the text box and filter out the picked up items.

Suggested description column - screenshot

  1. Select the Search Box.
  2. Go to the formula bar and clear the Value text.

A screenshot with a border around the formula bar

  1. Click Save to save your changes.

Exercise 3: Test and publish application

In this exercise, you will test, publish and give colleagues permission to use the application.

Task 1: Test application

In this task, you will test the application.

  1. Click on the Preview button.

A screenshot with an arrow pointing to the Preview button

  1. The Reserve and Picked up button should be visible and enabled.
  2. Search for cable. The gallery should show items that have the text cable in the name or description column.

A screenshot with the word cable in the search bar and a gallery showing items that have the text cable in their name or description column on the left side of the window

  1. Select one of the items, the Reserved by column value should be empty.
  2. Click on the Reserve button.

A screenshot of a border around the Reserved by field and an arrow pointing to the Reserve button

  1. The Reserve button should become disabled and the reserved by value will be set to your username. Click on the Picked up button.

A screenshot with a border around the reserved by field with your username and another border around the now-disabled reserve button

  1. The item should no longer show up on the gallery and the first item of the gallery should get selected.
  2. Close the preview.
  3. Do not navigate away from this page.

Task 2: Publish application

In this task, you will publish the application to Teams.

  1. Click on the Publish to Teams button.

A Screenshot with an arrow pointing to the publish to teams button

  1. Click Next.
  2. Click + add app as a tab.

A Screenshot with an arrow pointing to the plus icon for add app as a tab in the general box

  1. Click Save and close
  2. Select Teams and select the new Upcycle tab.

A Screenshot with an arrow pointing to the upcycle button

  1. The app should load. If the app is not loaded, refresh the page.

A screenshot of the loaded app

  1. Test the application in Teams and make sure it behaves as you expected.

Task 3: Give permissions

In this task, you will give your colleagues permission to create new items, edit items they created, delete items they created and read items created by other people.

  1. Select Power Apps and click on the See more link.

A screenshot with a border around the power apps button on the left side of the window and an arrow pointing to the see more link in the recent apps

  1. Click to open the Gadget table.
  2. Click Manage permissions.

A Screenshot with an arrow pointing to the manage permissions button

  1. Select Members, select Collaborate permission and click Save

A screenshot of the collaborate permission selected

  1. You may test the application with another user and see how it behaves.