in PowerApps, SharePoint

Show and hide controls in SharePoint list custom forms based on SharePoint Form modes in PowerApps

Custom Forms allow you to build customized experiences using Microsoft PowerApps for the new, edit and display forms for that SharePoint list. If you don’t like the default forms, then you can quickly build one to your needs.

By default, PowerApps will add a default Form control that handles the different modes – new, edit and display. You could have different forms for each and here is a blog post that shows you how to build one.

No doubt using a single form control makes it easier to manage your custom form, but what if you wanted to show and hide controls based on the form mode so you can present the right input controls to the user.

For example, here is a simple form:

SharePoint List Custom Form

SharePoint List Custom Form

What if you wanted to show the Project Owner only in Edit and Display forms, and not in the New form?

You can do that!

First, you will need to read the form mode. You can get that from the SharePoint Form available in your PowerApp using the enum property Mode.

SharePointForm1.Mode

This property will return 0, 1, 2 based on the form mode. Below are what these values correspond to:

  • 0 – Edit Mode
  • 1 – New Mode
  • 2 – Display Mode

You can now easily manage the visibility of a control, like the Project Owner field in our example, based on the form mode.

Here is how I manage the visibility in my example.

Select the Project Owner data card in the SharePoint Form

Type the following expression for the Visibile property:

If(SharePointForm1.Mode = 1, false, true)
Visibility based on SharePoint Form modes

Visibility based on SharePoint Form modes

This will ensure the field is hidden in the New form mode but visible in Edit and Display form modes.

New Form without the Project Owner:

Custom Form - Add New Project

Custom Form – Add New Project

Display Form with Project Owner:

Custom Form - View Project

Custom Form – View Project

Edit Form with Project Owner:

Custom Form - Edit Project

Custom Form – Edit Project

Now you can easily show and hide controls based on the SharePoint form mode!

Write a Comment

Comment