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:
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.
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)
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:
Display Form with Project Owner:
Edit Form with Project Owner:
Now you can easily show and hide controls based on the SharePoint form mode!