Click here to Skip to main content
15,178,967 members
Articles / PowerApps
Posted 15 Jun 2021

Tagged as


4 bookmarked

Power Apps for Professional Developers 2: How to build Power Apps

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
15 Jun 2021CPOL6 min read
In this article, we run through enabling PowerApps in Teams and step through the process of creating a simple, single-page form application from scratch.
Here we examine the difference between building PowerApps in Teams vs building them through the normal Power Apps UI by building small demo apps.

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

This is the second of three articles to show developers and technically-minded users why they should care about Power Apps within Teams. In the first article, we went through an overview of Power Apps and their integration in Teams. Hopefully by now, you have tried some of the ready-made demo apps and are familiar with the capabilities of Power Apps.

In this next article, we will run through enabling PowerApps in Teams and step through the process of creating a simple, single-page form application from scratch. We will do this by defining our data and creating a table to store entered values, then building the form. We can do everything in the PowerApps interface without ever leaving Teams. We will also add some code to get the form to submit data for the user. Let’s jump straight in.

Adding Power Apps in Teams

For our first app, let’s look at a typical business problem. Suppose you need to set up a work-from-home booking app. Power Apps within Teams is a natural fit, as all staff already use Microsoft Teams, so access and deployment should be simple. Although this app is for a work-from-home request, you could extend it to other situations where a staff member needs booking authorization from a manager, such as vacation or sick leave.

Let’s see how to build this app using Power Apps within Teams. First, ensure you have Microsoft Teams ready to go. If you have not yet installed Teams, you can look at some of the developer preview options which allow you to try for free. This gives you an opportunity to evaluate Power Apps within Teams and sell your plan to your organization with minimal cost.

First, we add Power Apps to our Teams environment. Open Teams and on the left-hand bar, click on the More Added Apps option (the three dots) and select More Apps. Search for Power Apps and install it.

Image 1

Once installed, open Power Apps and click Create an App. You will need to add your application to a valid team that you have access to. Hit create and name your application "Work from Home Request."

Image 2

This process will launch you into a new application with the default application designer screen so we can start building.

Setting up the Data

Let’s set up our data by creating a new table.

Image 3

We will call our table "WFHDetail", and it will store all the components of the form we will create to collect data from the users. Add a few columns to this table by using the + button and supplying a name and type. PowerApps supports several specialized data types, but most of the time, text or numbers will suffice. Create a few columns for Request Number, Employee Name, Manager Name, Start Date, Contact Number, Safety Assessed, and Approved.

Image 4

Creating a New Form

Once we create our data elements, we can create the form our users will complete. If we switch to our Tree view (the three stacked papers) we can see the default screen for our new project (screen1).

Let’s start from scratch by deleting all the elements attached to this screen and renaming it to "WFH Form".

With the screen selected, switch to the Insert view (the + icon under the Tree view) and click Label. Labels provide static information that can be used for headings or instructions. To quickly and easily add our table, we can insert an Edit form element. This places all the columns of our table into a form directly on our screen.

Image 5

The properties menu on the right sidebar panel allows us to modify the overall look and feel of the form. For our form, we want to change the Default mode from Edit to New, because we want the form to be used to fill our new work from home requests.

You can also click individual elements to modify their properties. For instance, we will remove the approve data element at this stage, as we don’t want employees populating that field.

We can also use a number of functions to make this form easier to fill out. Double-click on the Employee Name text box under the Advanced tab on the right sidebar, and click Unlock to change properties. When you have an element selected, you can tie that element to a function.

For the employee name, let’s tie this to the function User().FullName. This will allow us to populate the form using the name of the user logged into Teams, so the user will not need to fill out their name manually.

Image 6

Submitting Data

To submit our form, we also need to create a button that users can click when done. Make sure you don’t have Edit form selected, and insert a new button. Move the button below the form and double-click on it to change the label to "Submit Request".

Next to the function screen is a drop-down menu that allows you to change different events related to our form elements. We can add a function to the Submit Request button using the OnSelect event. In the function text box, type SubmitForm(‘Name of Form’). You will notice the function text box has text prediction functionality, which you may be able to use to auto-complete your function.

Image 7

We should also notify the user when a form has been successfully submitted, then clear the form. To do this, we are going to enter the following code in the form’s OnSuccess event:

NewForm(‘FormName’); Notify("Work from home request

This function does two things when the form is successfully created. First, it creates a new instance of the form using the NewForm. Then it creates a notification banner on the top of our application using the Notify method. Save your Power App and click the Preview button to view your form and enter some data.

Image 8

You will notice the employee’s name is filled out when the form is first opened. If you fill out the other fields and hit Submit Request, the form should clear and the success banner should be displayed on top. If we go back to our data source, you will see that the form has submitted data into the table we created.

Image 9

Next Steps

Using Power Apps to set up a simple application to record data right within Teams is fairly straightforward. With very limited code and no additional infrastructure, we created a simple, single-form application that allows users to submit requests to a central datastore.

In the next article, we’ll add some polish to this application to make it into something you could use in your own environment. To do this, we will add a menu/portal system that uses the client’s Teams environment settings. Then, we’ll publish the application and export the completed solution.

Check out our 7-Step Guide to Low-Code App Development to get starting using Power Apps today.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Glenn Prince
United States United States
Hi! I'm a Solution Architect, planning and designing systems based in Denver, Colorado. I also occasionally develop web applications and games, as well as write. My blog has articles, tutorials and general thoughts based on more than twenty years of misadventures in IT.

Comments and Discussions

-- There are no messages in this forum --