Creating Forms and Views
Complete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks and see fewer ads — read each lesson on a single page with Pro
Mastering Model-Driven App Configuration: Forms and Views
Introduction to Model-Driven App Data Presentation
When you build a model-driven app in the Microsoft Power Platform, you are essentially creating a sophisticated interface on top of the Microsoft Dataverse. Unlike canvas apps, where you manually drag and drop every pixel to create a custom layout, model-driven apps follow a data-first philosophy. This means that once you define your tables, columns, and relationships, the platform generates the user interface for you. However, the default interface is rarely enough for a real-world business process. That is where Forms and Views come in.
Forms and Views are the primary mechanisms for how users interact with your data. A form is the interface used for data entry and editing, while a view is the interface used for data discovery and analysis. If you master these two components, you have mastered the core of the user experience in Power Platform. Without well-configured forms, users struggle to input data accurately, leading to poor data quality. Without well-configured views, users cannot find the information they need, leading to decreased productivity. This lesson will guide you through the technical configuration, design principles, and best practices required to build professional-grade interfaces.
Understanding Model-Driven Forms
In a model-driven app, a "Form" is not just a container for text boxes. It is a structured, reactive component that changes based on the user's security role, the state of the record, and the business logic you define. When you open the Form Designer, you are working with a canvas that understands the underlying schema of your table.
Types of Forms
Before diving into the design, it is important to distinguish between the different types of forms available:
- Main Forms: These are the workhorses of your application. They are used for data entry, editing, and viewing record details. They support business rules, JavaScript scripting, and complex layouts.
- Quick Create Forms: These are simplified forms designed for rapid data entry. They allow users to create a new record from a lookup field or a subgrid without leaving their current context.
- Quick View Forms: These are read-only forms used to display information from a related record within the main form of another table. For example, you might show a customer's contact details on an Order form.
- Card Forms: These are used primarily in mobile applications to display a summary of a record in a list view.
Callout: Main Forms vs. Quick Create Forms Think of a Main Form as a detailed document where you fill out every possible field, including attachments, sub-tables, and complex logic. A Quick Create Form is like a sticky note—it only contains the absolute minimum information required to get a record into the system quickly. Use Quick Create for high-frequency tasks to keep the user's flow uninterrupted.
Designing an Effective Main Form
The Main Form designer is divided into tabs, sections, and columns. A well-designed form should follow a logical flow that matches the business process of the user.
- Tabs: Use these to categorize large amounts of data. A "General" tab might hold core information, while a "Financials" tab holds billing data. Keep the number of tabs limited to avoid overwhelming the user.
- Sections: Within a tab, sections group related fields together. Always use descriptive labels for sections. If you have a section for contact information, label it "Contact Information," not "Section 2."
- Columns (Fields): Drag and drop your table columns into the sections. Ensure that the most important fields are at the top of the first section.
Tip: Always organize your fields based on the "tab order." Users often navigate through forms using the 'Tab' key on their keyboard. If your fields are scattered, the focus will jump around the screen, creating a frustrating experience.
Configuring Views for Data Discovery
If forms are for input, views are for navigation. A view defines how a list of records is presented to the user. You can configure which columns are visible, the sorting order, the filtering criteria, and even the width of the columns.
Types of Views
- System Views: These are created by the system administrator and are available to all users. Examples include "Active Accounts" or "My Open Tasks."
- Personal Views: These are created by individual users to satisfy their own specific reporting needs. They are not shared with the rest of the organization unless the user chooses to share them.
- Public Views: A subset of system views that are visible to everyone in the app.
Designing a High-Performing View
When configuring a view, you must balance the amount of information displayed with the performance of the system.
- Select Essential Columns: Do not add every single column to a view. Only add columns that are necessary for the user to identify the record or make a quick decision.
- Define Filter Criteria: Use the filter builder to ensure users only see the data they need. For example, an "Open Leads" view should have a filter where "Status" equals "Open."
- Sorting: Set a default sort order. Usually, sorting by "Created On" in descending order is the most helpful, as it puts the newest records at the top.
Note: Be careful with complex filters involving many related tables (joins). Adding too many filters that require the system to look up information from multiple related tables can significantly slow down the loading time of your view.
Implementing Business Logic on Forms
One of the most powerful features of model-driven forms is the ability to enforce business rules without writing code. This is done through the "Business Rules" designer.
Using Business Rules
Business rules allow you to:
- Show or hide fields based on user input.
- Set field values (e.g., setting a default "Priority" to "Medium").
- Validate data (e.g., ensuring an "End Date" is after a "Start Date").
- Make fields mandatory or optional dynamically.
Step-by-Step: Creating a simple Business Rule
- Open your table in the Power Apps maker portal.
- Navigate to the "Business rules" tab.
- Click "New business rule."
- In the designer, define the "Condition" (e.g., "If Status equals 'Closed'").
- Define the "Action" (e.g., "Lock the 'Project Name' field").
- Save and Activate the rule.
When to Use JavaScript
While business rules cover 80% of common requirements, there are times when you need more control. This is where Client-side JavaScript comes into play. You can upload JavaScript files as "Web Resources" and attach them to form events like onLoad, onChange, or onSave.
// Example: Validating a field value on change
function validateProjectCode(executionContext) {
var formContext = executionContext.getFormContext();
var projectCode = formContext.getAttribute("new_projectcode").getValue();
// Check if the code starts with 'PRJ-'
if (projectCode != null && !projectCode.startsWith("PRJ-")) {
alert("Project code must start with 'PRJ-'.");
formContext.getAttribute("new_projectcode").setValue(null);
}
}
Warning: Avoid excessive use of JavaScript. Every line of code you add is something that can break during platform updates. Always prioritize Business Rules, then Power Automate, and use JavaScript only as a last resort.
Best Practices for Form and View Configuration
To ensure your app remains maintainable and user-friendly, follow these industry standards:
1. Consistent Naming Conventions
Use a prefix for all your custom components. If your organization's prefix is contoso_, ensure all your custom tables and columns follow this pattern. This prevents naming collisions and makes it easier to identify your custom work within the system.
2. The "Less is More" Approach
Do not put 50 fields on a single form. Use tabs to break information into logical chunks. If a user only needs to see specific information 10% of the time, put it in a separate tab or a separate form entirely.
3. Use Help Text
Every column you create has a "Description" property. This description appears as a tooltip when a user hovers over the field label in the form. Use this to provide context or instructions on how to fill out the field.
4. Optimize for Mobile
Model-driven apps are responsive by default, but complex layouts can look messy on a phone screen. Test your forms on a mobile device or use the "Mobile" preview in the form designer to ensure that key fields are visible and easy to tap.
5. Standardize View Layouts
If you have multiple views for a table, try to keep the column order consistent. If "Account Name" is the first column in the "Active Accounts" view, it should also be the first column in the "All Accounts" view.
Comparison Table: Common Configuration Options
| Feature | Best Used For | Complexity |
|---|---|---|
| Business Rules | Simple UI logic (hide/show, set values) | Low |
| JavaScript | Complex validation, external API calls | High |
| Quick View Forms | Showing related data snippets | Low |
| Subgrids | Displaying a list of related records | Low |
| Personal Views | User-specific data analysis | Low |
Common Mistakes and How to Avoid Them
Mistake 1: Not Using Security Roles
Many developers build a single, massive form that contains fields for every department in the company. They then try to use JavaScript to hide fields based on the user's role. This is a security risk and a maintenance nightmare.
- The Fix: Create separate forms for different roles and use "Form Security Roles" to assign specific forms to specific security groups. If a user doesn't need to see the "Financials" tab, they shouldn't even have access to the form that contains it.
Mistake 2: Ignoring Data Types
Users often try to force data into the wrong type of column. For example, using a "Text" column to store a date because they don't want to deal with date formatting.
- The Fix: Always use the correct data type (Date, Choice, Lookup, Currency). This ensures that the system provides the correct input controls (like a date picker) and allows for accurate filtering and reporting in your views.
Mistake 3: Overloading the "Main" Form
When a form has too many fields, it becomes slow to load, and users get overwhelmed.
- The Fix: Audit your forms regularly. If a field hasn't been updated in six months, it might not need to be on the main form. Consider moving it to a secondary tab or a "Details" area.
Mistake 4: Hardcoding Values
Hardcoding values in JavaScript or Business Rules is a common trap. If you hardcode a status value like "Active" (which might have an underlying ID of 1), and that ID changes, your code will break.
- The Fix: Always use logical names or metadata lookups rather than hardcoded IDs or raw text strings.
Advanced Configuration: Customizing the Command Bar
While forms and views handle data, the Command Bar (the ribbon at the top of the app) handles actions. You can customize the command bar to add buttons that trigger specific actions, like "Generate Invoice" or "Export to PDF."
To customize the command bar:
- Open the table in the Power Apps portal.
- Select "Command bar" from the menu.
- Choose the area you want to edit (Main form, Main grid, or Subgrid).
- Use the "Command Designer" to add buttons and associate them with Power Fx formulas or JavaScript actions.
Callout: Power Fx in Command Bars The introduction of Power Fx in command bars has revolutionized app development. You can now write simple, Excel-like expressions to perform actions directly on the command bar. For example,
Patch(Accounts, Self.Selected.Item, {Status: 'Active'})can update a record's status with a single click.
Step-by-Step: Creating a Professional Form Layout
Let's walk through the process of creating a "Customer Onboarding" form to see these concepts in action.
Phase 1: Structure
- Start with a new Main Form.
- Add a Header section. Include fields that should always be visible, such as "Account Name" and "Owner."
- Add a Tab named "Core Details."
- Add two columns in this tab. In the left column, add "Contact Info" (Phone, Email, Website). In the right column, add "Categorization" (Industry, Region, Tier).
Phase 2: Logic
- Create a business rule: "If Industry is 'Retail', show the 'Store Location' field."
- Create a business rule: "If Tier is 'Gold', make the 'Account Manager' field mandatory."
Phase 3: Refinement
- Navigate to the "Form Properties" and ensure the tab order is set correctly.
- Add a subgrid to the bottom of the form to display "Related Opportunities."
- Set the subgrid to "Show related records" and select the "Opportunities" table.
Phase 4: Testing
- Save and Publish the form.
- Open the app and navigate to the Accounts table.
- Open a record and verify that the sections are laid out correctly and the business rules trigger as expected.
The Role of Views in Reporting
Views are the foundation of your reporting strategy. When you want to visualize data in a Dashboard, you typically use a "Chart" that is based on a specific "View." If your view is filtered correctly, your chart will be accurate.
Creating a View with Related Data
Sometimes you need to see data from a related table. For example, in an "Accounts" view, you might want to see the name of the "Primary Contact."
- Open the View Designer.
- Click "Add column."
- Select the "Related" tab.
- Expand the "Primary Contact" relationship and select the "Full Name" column.
- The view will now show the name of the contact, even though the data lives in a different table.
Ensuring Quality and Security
Data quality is not just about the fields on the form; it is about the constraints you place on them. Always use Business Required fields for data that is essential for your business processes. For data that is "nice to have," use Business Recommended fields. This provides a visual cue to the user (a blue plus icon) without forcing them to fill it out.
Regarding security, remember that field-level security can be applied to sensitive columns (like "Credit Score" or "Salary"). Even if a user has access to the form, they will not see the data in these fields unless they have the appropriate Field Security Profile. This is a critical layer of protection that should be configured alongside your form layout.
Key Takeaways for Success
- Forms are for Input, Views are for Discovery: Keep this distinction in mind. If you find yourself trying to force a lot of data into a view, you are likely missing a dashboard or a report. If you are struggling to make a form usable, you likely need to split it into multiple forms or tabs.
- Prioritize Configuration over Customization: Always look for a native "out-of-the-box" way to solve a problem before reaching for JavaScript or complex plugins. The platform is designed to be configured; every custom line of code adds technical debt.
- Consistency is Key: Users adapt to apps much faster if the interface is predictable. Use consistent naming, standard field placements, and uniform tab structures across all your tables.
- Test on Multiple Devices: A form that looks great on a 27-inch monitor might be unusable on an iPad. Always preview your forms in the mobile-responsive view to ensure they remain functional for users in the field.
- Leverage Business Rules: They are the easiest way to make your app "smart." They are easy to maintain, work across all platforms, and require no coding knowledge, making them the best tool for most UI-related logic.
- Iterate Based on User Feedback: Your first design will rarely be your best. Watch how your users interact with the forms. If they are constantly scrolling to find a specific field, move that field to the top of the form. If they are using personal views to filter data, consider creating a system view that matches their needs.
- Document Your Logic: If you implement complex business rules or JavaScript, document them. Future developers (or your future self) will thank you when it comes time to update the system or troubleshoot an issue.
By focusing on these principles, you will be able to build model-driven apps that are not only functional but also highly efficient and pleasant for your users to interact with. Remember that the goal of the Power Platform is to empower users to get their work done, and the form and view are the primary tools they use to do exactly that.
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons