Understanding Form Modes in PowerApps (Edit, New, View) – A Comprehensive Guide
Introduction
PowerApps provides forms as an essential tool for interacting with data sources. Forms allow users to view, edit, and create records, making them a fundamental component of most applications.
PowerApps forms operate in three key modes:
✅ New Mode – For adding new records.
✅ Edit Mode – For modifying existing records.
✅ View Mode – For displaying records in a read-only format.
These modes ensure that forms behave differently based on user actions. Understanding how they work is crucial for designing effective PowerApps applications.
1. What are Form Modes in PowerApps?
A form’s mode determines how it interacts with the data source. It affects whether users can input new data, edit existing data, or only view data.
Form Mode | Description | Function Used to Set Mode |
---|---|---|
New Mode (FormMode.New ) | Used to create a new record. Fields are blank. | NewForm(FormName) |
Edit Mode (FormMode.Edit ) | Allows users to modify an existing record. Fields are pre-filled. | EditForm(FormName) |
View Mode (FormMode.View ) | Displays a record in read-only mode. Users cannot edit fields. | ViewForm(FormName) |
2. How to Set Form Modes in PowerApps?
2.1 Setting Form Mode Using the DefaultMode Property
Each form in PowerApps has a DefaultMode property that determines its initial behavior.
How to Set Default Mode for a Form?
1️⃣ Select the Form control.
2️⃣ Go to the Properties pane.
3️⃣ Set the DefaultMode property using one of the following:
Form1.DefaultMode = FormMode.New // For new records
Form1.DefaultMode = FormMode.Edit // For editing records
Form1.DefaultMode = FormMode.View // For read-only display
2.2 Switching Between Form Modes Using Functions
PowerApps allows users to dynamically switch between form modes using built-in functions:
🔹 New Mode Function (Clears fields for a new record)
NewForm(Form1)
🔹 Edit Mode Function (Loads existing data for editing)
EditForm(Form1)
🔹 View Mode Function (Displays data in read-only mode)
ViewForm(Form1)
🔹 Reset Form Function (Clears all input fields)
ResetForm(Form1)
🔹 Submit Form Function (Saves data to the connected data source)
SubmitForm(Form1)
3. Practical Examples of Using Form Modes
3.1 Creating a New Record (New Mode)
Scenario: A user wants to add a new employee to a database.
Steps:
1️⃣ Insert an Edit Form and set the DataSource property to Employees
.
2️⃣ Insert a “New” Button and set its OnSelect property:
NewForm(Form1)
3️⃣ Insert a Submit Button and set its OnSelect property:
SubmitForm(Form1)
ResetForm(Form1)
4️⃣ The form opens in New Mode, allowing users to enter new data.
5️⃣ Clicking Submit saves the record to the Employees
table and clears the form.
What Happens?
✅ Fields are empty when the form loads.
✅ The user enters data and clicks Submit.
✅ The record is saved to the database.
✅ The form resets for another entry.
3.2 Editing an Existing Record (Edit Mode)
Scenario: A user selects an employee from a list and updates the details.
Steps:
1️⃣ Insert a Gallery to display employee records.
2️⃣ Set the Gallery’s Items property:
Employees
3️⃣ Insert an Edit Form and set its DataSource to Employees
.
4️⃣ Set the Item property of the form:
Gallery1.Selected
5️⃣ Insert an “Edit” Button and set its OnSelect property:
EditForm(Form1)
6️⃣ Add a Submit Button with the following OnSelect property:
SubmitForm(Form1)
What Happens?
✅ Selecting an employee loads their details in the form.
✅ Clicking Edit switches the form to Edit Mode.
✅ The user modifies the details and submits the form.
✅ Changes are saved to the database.
3.3 Viewing a Record Without Editing (View Mode)
Scenario: A user selects an employee record to view details but not edit.
Steps:
1️⃣ Use the same Gallery setup from the Edit Mode example.
2️⃣ Insert a View Button and set its OnSelect property:
ViewForm(Form1)
3️⃣ Change form fields to Display Mode:
- Select each input field.
- Set DisplayMode to:
DisplayMode.View
What Happens?
✅ Selecting an employee loads their details in the form.
✅ Clicking View switches the form to read-only mode.
✅ Users cannot edit any fields.
4. Best Practices for Using Form Modes
✅ Use navigation buttons – Provide clear buttons for switching between New, Edit, and View modes.
✅ Prevent accidental data loss – Use ResetForm(Form1)
when switching to New Mode.
✅ Restrict editing for unauthorized users – Control access using If() conditions.
✅ Provide success messages – Use Notify("Record saved successfully!", NotificationType.Success)
.
✅ Optimize data loading – Set the form’s Item property properly to avoid performance issues.
5. Conclusion
✅ New Mode (FormMode.New
) – Creates new records.
✅ Edit Mode (FormMode.Edit
) – Updates existing records.
✅ View Mode (FormMode.View
) – Displays records without editing.
✅ Functions like NewForm()
, EditForm()
, and ViewForm()
allow dynamic switching.
✅ Best practices help create user-friendly and efficient applications.
By mastering form modes in PowerApps, you can build powerful, interactive applications that enhance data management. 🚀
Would you like a step-by-step tutorial with screenshots for implementing these form modes?