gray cat standing in two feet

Fixing the Bug with Modern PowerApps Controls: Form.Unsaved Not Working

Last Updated: January 15, 2025By

If you’re working with PowerApps and using modern controls, you know how exciting those sleek new features can be. But what if one of those features suddenly stops working as expected? That’s exactly what happened to me recently when I encountered a bug with the Form.Unsaved property in modern forms. After some troubleshooting, I found a workaround, and I’m sharing it here to save you the headache.

Understanding the Form.Unsaved Bug

PowerApps modern controls are labeled with “Preview,” but they generally perform well. Over the past few months, I’ve used modern controls, including modern forms and buttons, without issues—until now.

The problem crept up when I started using the Form.Unsaved property in a modern form. This property is supposed to indicate if there are changes in the form that haven’t been saved. When used correctly, Form.Unsaved can help enable or disable buttons based on form status. It works perfectly in classic forms. However, in modern forms, something unexpected happens.

Here’s the bug in action: When the app initializes, the Form.Unsaved property seems fine. But when the form is reset, the property flags the form as “unsaved,” even when no changes exist. This behavior can lead to buttons being incorrectly enabled or disabled. Not great for user experience, right?

Let’s break it down further with an example.

Classic vs. Modern Forms: What’s Different?

To give you a visual, I tested this in a basic recipe app where I set up both a classic form and a modern form side by side.

How It Works in Classic Forms

In classic forms, the Form.Unsaved logic works exactly as intended. A button can check whether the form is unsaved and adjust its display mode accordingly. Here’s a simplified version of the button logic for classic forms:

If(FormClassic.Unsaved, DisplayMode.Edit, DisplayMode.Disabled)

No surprises here. If the form is unsaved, the button is enabled (DisplayMode.Edit). If not, it’s disabled (DisplayMode.Disabled). Everything stays consistent—even after resetting the form or making changes.

Modern Forms and the Bug

Modern forms, however, tell a different story. Let’s say you set up button logic like this:

If(FormModern.Unsaved, DisplayMode.Edit, DisplayMode.Disabled)

Initially, this works fine. But after you reset the form, the modern form treats the Form.Unsaved property as true—even when no changes have been made. This problem results in buttons being incorrectly enabled, which could confuse users or cause unwanted actions in your app.

Here’s another twist: The bug doesn’t show up immediately during setup. It only becomes evident during live use, which can be really frustrating.

Identifying a Workaround

Seeing how inconsistent the behavior was, I knew I needed a workaround before deploying the app. Microsoft has acknowledged the bug, but there’s no fix yet. Thankfully, you can sidestep this issue with some clever logic.

The workaround involves using conditional visibility instead of relying solely on Form.Unsaved. Here’s how you can do it.

Workaround Code Solution

Instead of tying the button’s display mode directly to Form.Unsaved, you add logic to verify if fields in the form are truly unsaved. Here’s an example:

If(
    Or(
        IsBlank(DataCardValue5.Value),
        IsBlank(DataCardValue6.Selected.Value),
        IsBlank(AddPicture2.Media)
    ),
    DisplayMode.Disabled,
    DisplayMode.Edit
)

This approach checks specific fields (like text boxes) to ensure they’re not blank before enabling the button. While this might get trickier in large, complex forms, it’s a reliable solution.

You can use color coding or other visual cues in your app to signal the unsaved state. For example, you could highlight required fields in red until the user fills them out.

Testing the Workaround

To verify this fix, I tested it side by side with the classic form logic. The new condition worked seamlessly, enabling and disabling the button accurately—even in modern forms. Though this method requires more initial setup, it’s a solid alternative until Microsoft resolves the issue.

What to Watch for with Modern Forms

Beyond the Form.Unsaved problem, modern forms have some quirks. For example, unexpected pop-ups may appear when interacting with dropdowns or other controls. These minor annoyances don’t break functionality but can be distracting for users.

If you need to stick with modern forms, I recommend testing thoroughly. Use conditional logic wherever possible to create a polished user experience.

Wrapping Up

While modern controls in PowerApps offer great features, bugs like this remind us to stay cautious during development. The Form.Unsaved issue in modern forms is problematic, but with the workaround above, you can keep your app running smoothly.

Got more questions or run into other issues with PowerApps? Drop a comment below. If you found this guide helpful, give it a thumbs-up and share it with your fellow PowerApps enthusiasts.

Until next time, keep exploring, building, and making your apps work for you! Happy coding!

Leave A Comment