Patching Dataverse OptionSet - Yes/No

You're knee-deep in Power Apps, building a slick interface with dropdowns for your users to effortlessly update Dataverse. Then, bam! You hit a snag trying to patch a simple Yes/No column.

It turns out those handy DropDown controls aren't as straightforward as they seem when it comes to boolean fields. Sure, workarounds exist, but who wants to wrestle with complex logic when you have a deadline looming?

My solution? Embrace the Toggle control! This often-overlooked UI element is a perfect fit for Yes/No fields. It provides a clean, intuitive user experience and seamlessly integrates with Dataverse.

Toggle Controls in a Canvas App

Here’s an example of a code you can use to Patch the column in Dataverse using the Toggle control:

Patch(
    DVTable, //replace with your table
    Gallery1.Selected, //replace with Defaults(DVTable) to add a new row
    {
        YesNo: Toggle1.Checked
    }
);

In my latest project, I was drowning in a sea of Dropdowns, each painstakingly configured to capture Yes/No responses. Switching to Toggles was like a breath of fresh air. It simplified my app logic and, let's be honest, just looks cleaner.

If for some reason, you still wish to use a Dropdown for the job. Here’s an example:

Patch(
    DVTable, //replace with your table
    Gallery1.Selected, //replace with Defaults(DVTable) to add a new row
    {
        YesNo: If(Dropdown1.Selected.Value = "Yes", true, false)
    }
);

Hope this was helpful. Thanks!

Previous
Previous

Building a Chat Interface in Power Apps for Case Management

Next
Next

User Check for Multi-Select Person Column