How to: Hide fields in SharePoint list forms using PowerApps
Posted
Thursday, November 16, 2017 10:39 AM
by
CoreyRoth
I’ve been building forms for a number of business processes lately using PowerApps and some of my tenants recently received the ability to customize forms in SharePoint lists using PowerApps. One common scenario is that you might want to show or hide different fields depending on whether the user is creating a new item or editing an existing one. I tried a number of approaches while experimenting with the visible field. It wasn’t quite obvious to me at first, so after watching the following video that Chris Webb sent me a link for, I figured it out.
For our scenario, we have a simple travel request form. The requester will fill out fields on where they are going. The approver will edit the form and fill in comments and mark it as approved. The requester shouldn’t see these fields. In this example, we could actually use Approval Flows and what not, but for this example we are keeping it simple. Let’s start by looking at our default form.
Start by selecting the field you want to hide and then click on the Visible property.
Now, set the value equal to the following formula.
If(SharePointForm1.Mode = FormMode.New, false, true)
This hides the field when the form is in new item mode and shows it for view and edit. You can customize this to your needs for other views as well. You can preview what the form looks like in different modes now by clicking on SharePointForm1 and then changing the Default mode property between New and Edit. For example, here is what my New form looks like now.
Save and Publish your form and then you can try it from within SharePoint. Now, when I click on the New button, the other fields are hidden.
When I edit an existing item, we see the fields that we hid on the new form.
Like many things in PowerApps, hiding fields is pretty simple once you know the right formula. It took me a bit to figure this out because I think I was approaching this more from my developer background. When I start to think about the old Excel formulas I used to use, it actually makes a lot of sense.