Building and Connecting Forms to Table Data in Power Apps
Power Apps empowers organizations to rapidly develop business applications with minimal coding. A common requirement in a Canvas App is creating a form that allows users to enter, edit, and manage data stored in a table. Forms provide an intuitive way to connect users with essential data sources such as Dataverse, SharePoint Lists, Excel files, and SQL Server tables, among many other connectors.
By leveraging forms, organizations can create robust solutions like employee management systems, customer portals, inventory applications, and service request systems. Power Apps forms are specifically designed to facilitate the creation, editing, and display of records from connected tables and data sources. In this article, we'll explore how to build a form from scratch and seamlessly connect it to table data within Power Apps.
What is a Form in Power Apps?
At its core, a Form is a control within Power Apps that serves as the primary interface for users to interact with data. It acts as a structured gateway for input, display, and modification of information.
Consider an Employee Registration Form as a practical example. Through such a form, users can perform several key data operations:
- Create Records: Add new entries, like a new employee's details.
- Edit Records: Modify existing information for an employee.
- View Records: Display an employee's details in a read-only format.
- Update Records: Save changes made to a record.
- Submit Information: Transmit entered data to the underlying data source.
The typical workflow involving a form is straightforward:
User Input → Form Control → Connected Table → Store Data → Display Records
Why Use Forms in Power Apps?
Forms offer significant advantages for application development and user experience:
- Easy Data Entry: They provide a structured, user-friendly interface that simplifies the process of inputting data, reducing errors and improving efficiency.
- Built-In Validation: Forms can be configured with validation rules to ensure data accuracy and integrity before it's saved to the data source.
- Fast Development: Power Apps forms are quick to set up and configure, significantly accelerating the application development lifecycle, especially when dealing with common CRUD (Create, Read, Update, Delete) operations.
- Dataverse Integration: Forms seamlessly integrate with Dataverse, offering robust security, scalability, and rich data modeling capabilities for enterprise-grade solutions.
- SharePoint Integration: Effortlessly connect to SharePoint lists, making it easy to build apps on top of existing SharePoint data.
- User-Friendly Interface: Designed to be intuitive, forms enhance the overall user experience by providing a clear and organized way to interact with business data.
Form Architecture Overview
Understanding the underlying architecture helps in building effective forms. The flow is generally as follows:
Canvas App → Form Control → Data Source → Table → Store Records
Power Apps forms work directly with tables and records stored in connected data sources, acting as a bridge between your app's UI and your backend data.
Building a Form in Power Apps: A Step-by-Step Guide
Let's walk through the process of creating an employee registration form that captures and manages employee information, storing it in a Dataverse table and displaying records in a gallery.
Step 1: Create a Canvas App
Begin by setting up your Power Apps environment:
- Navigate to make.powerapps.com.
- From the left navigation pane, select Apps, then click + New app > Canvas.
- Choose either Tablet Layout or Phone Layout based on your application's primary usage. For this example, a tablet layout is suitable.
Step 2: Create a Table in Dataverse
Dataverse provides a secure and scalable platform for your application's data. We'll create a new table to store employee details:
- In the Power Apps maker portal, select Tables from the left navigation.
- Click + New table.
- Name your table, for instance,
EmployeeDetails. - Add the necessary columns (fields) to this table:
EmployeeName(Text)Email(Text/Email)Department(Text)PhoneNumber(Text)Location(Text)- Save the table. Dataverse tables can be created directly within the Power Apps interface, streamlining your development process.
Step 3: Connect Your Data Source
Now, connect your newly created Dataverse table to your Canvas App:
- In your Canvas App studio, select Data from the left navigation.
- Click + Add data.
- Search for and select Dataverse.
- From the list of available tables, choose your
EmployeeDetailstable.
Power Apps supports multiple data sources that store information as tables and records, making it highly flexible.
Step 4: Insert and Configure an Edit Form
The Edit form control is central to data entry and modification:
- Go to Insert from the top menu, then expand Forms, and select Edit form.
- Rename the form control to something descriptive, like
frmEmployee. - With
frmEmployeeselected, go to the Properties pane on the right. Set its DataSource property to yourEmployeeDetailstable.
Forms automatically connect to the selected table, inferring the available fields.
Step 5: Add Fields to Your Form
Once the form is connected to the data source, you can add the specific fields you want users to interact with:
- With
frmEmployeeselected, click Edit fields in the Properties pane. - Click + Add field and select the columns you created in Step 2:
EmployeeName,Email,Department,PhoneNumber, andLocation.
Your form will now display input controls for each of these fields, creating your basic employee entry form.
Step 6: Set the Form Mode
The form's mode dictates its behavior (new record, edit record, view record). For creating new records, set the DefaultMode property of frmEmployee:
- Set
DefaultMode=FormMode.New
Other useful modes include:
FormMode.Edit: For modifying existing records.FormMode.View: For displaying records in a read-only state.
Step 7: Add a Submit Button
A button is needed to save the data entered into the form:
- Go to Insert > Button.
- Set the button's Text property to "Submit".
- Set the button's OnSelect property to:
SubmitForm(frmEmployee)
The SubmitForm() function sends the data from the form controls to the connected table. The workflow is: User Enters Data → Submit Button → SubmitForm() → Save Record.
Step 8: Display a Success Message
Provide user feedback after a successful submission:
- Select
frmEmployee. - Go to its OnSuccess property (this property fires when
SubmitForm()completes successfully). - Set it to:
Notify("Record Saved Successfully", NotificationType.Success)
This will display a green notification banner, confirming the record has been saved.
Step 9: Add a Gallery to Display Records
To see the saved records, add a gallery:
- Go to Insert > Gallery > Vertical gallery.
- Rename the gallery to
galEmployees. - Set the gallery's Items property to:
'EmployeeDetails'
This gallery will now display all records from your EmployeeDetails table. Gallery controls are commonly used to display records from connected tables in a flexible and customizable layout.
Step 10: Enable Editing of Existing Records
To allow users to edit records directly from the gallery:
- Select the gallery (
galEmployees). - Set the OnSelect property of the gallery (or an icon within the gallery template) to:
EditForm(frmEmployee); Select(Parent) - Select
frmEmployee. - Set its Item property to:
galEmployees.Selected
Now, when a user selects an item in the gallery, the form will switch to EditMode and populate with the details of the selected record. The workflow is: Select Record → Load Form → Edit Data → Save Changes.
Step 11: Create a "New Record" Button
To allow users to clear the form and start a new entry:
- Insert another Button.
- Set its Text property to "New Employee".
- Set its OnSelect property to:
NewForm(frmEmployee)
This will reset frmEmployee to its NewForm mode, presenting a blank form ready for a new entry.
Step 12: Add a Reset Form Functionality
Sometimes, users might want to discard changes or clear fields without submitting:
- Insert another Button.
- Set its Text property to "Clear Form".
- Set its OnSelect property to:
ResetForm(frmEmployee)
This function clears all fields in the specified form, reverting them to their initial state.
Real-World Applications of Power Apps Forms
The principles learned above are foundational for a wide range of business applications:
Employee Registration System
This system allows employees to register and update their information. Key fields include EmployeeName, Email, Department, and PhoneNumber. The workflow involves entering information, submitting the form, storing data in Dataverse, and displaying all employees in a gallery, creating a comprehensive employee database.
Customer Management Application
Forms are essential for CRM solutions. Fields like CustomerName, Email, Phone, and Address can be captured. Functions include creating, editing, deleting, and viewing customer records, resulting in a custom CRM application built on Power Apps.
Help Desk Ticket System
Users can create new support tickets with fields such as TicketTitle, Description, Priority, and Status. The workflow includes creating a ticket, submitting it, storing the record, and assigning it to a technician, leading to efficient support ticket management.
Common Form Functions in Power Apps
These are the core functions you'll use when working with forms:
SubmitForm(frmEmployee): Saves the data currently in the form to the connected data source.NewForm(frmEmployee): Clears the form and sets it to "new record" mode, ready for fresh data entry.EditForm(frmEmployee): Sets the form to "edit record" mode, populating it with the data from the form'sItemproperty.ViewForm(frmEmployee): Sets the form to "read-only" mode, displaying data without allowing edits.ResetForm(frmEmployee): Clears all fields in the form and discards any unsaved changes.
Best Practices for Power Apps Forms
To build robust and user-friendly forms, consider these best practices:
- Use Dataverse When Possible: For structured applications requiring security, scalability, and integration with Dynamics 365, Dataverse is the recommended data source.
- Use Meaningful Field Names: Ensure your form fields (and underlying column names) are clear and descriptive, like
EmployeeNameorDepartment, improving maintainability and user understanding. - Validate User Input: Implement validation rules to prevent incorrect or incomplete data from being saved, ensuring data quality.
- Use Notifications: Provide immediate feedback to users using
Notify()for success messages, errors, or warnings. - Display Records in a Gallery: Always pair forms with galleries to allow users to easily view, select, and manage the records they've created or edited.
- Use Responsive Design: Design your forms to adapt to different screen sizes (mobile, tablet, desktop) for a consistent user experience across devices.
Common Challenges and Solutions
Even with best practices, you might encounter issues:
- Form Not Saving: Verify that the
DataSourceproperty of your form is correctly connected to your table and that your submit button'sOnSelectproperty correctly callsSubmitForm(). - Missing Fields in Form: Check the
Edit fieldsconfiguration of your form to ensure all desired fields have been added. - Blank Gallery: Confirm that the
Itemsproperty of your gallery is correctly set to your data source (e.g.,'EmployeeDetails'). - Permission Issues: Ensure that the user running the app has appropriate permissions to read and write to the connected data source.
Benefits of Building Forms in Power Apps
The effort invested in mastering forms yields significant benefits:
- Faster Development: Achieve rapid application deployment with minimal coding.
- Better User Experience: Provide intuitive and easy-to-use interfaces for data interaction.
- Built-In Validation: Enhance data reliability and consistency.
- Multiple Data Sources: Connect to Dataverse, SharePoint, SQL Server, Excel, and more.
- Enterprise Ready: Build scalable and secure applications suitable for business-critical processes.
Conclusion
Building forms and connecting them to table data is one of the most fundamental and powerful skills in Power Apps development. Forms provide an efficient and user-friendly way to collect, edit, and display information while seamlessly integrating with a multitude of data sources like Dataverse, SharePoint, SQL Server, and Excel.
Whether you're developing sophisticated employee management systems, dynamic customer portals, efficient inventory applications, approval workflows, or comprehensive CRM solutions, Power Apps forms offer a fast, scalable, and professional way to manage business data and deliver exceptional user experiences. By following this guide, you now have the foundational knowledge to create powerful data-driven applications tailored to your organization's needs.