in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

How to: Hide fields in SharePoint list forms using PowerApps

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.

Screen Shot 2017-11-16 at 10.25.25 AM

Start by selecting the field you want to hide and then click on the Visible property. 

Screen Shot 2017-11-16 at 10.26.42 AM

Now, set the value equal to the following formula.

If(SharePointForm1.Mode = FormMode.New, false, true)

Screen Shot 2017-11-16 at 10.29.06 AM

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.

Screen Shot 2017-11-16 at 10.33.43 AM

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.

Screen Shot 2017-11-16 at 10.35.46 AM

When I edit an existing item, we see the fields that we hid on the new form.

Screen Shot 2017-11-16 at 10.37.19 AM

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.

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2015 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems