You created a list with a bunch of columns. Great!
Now you want to hide some of them in the NewForm or EditForm. Not so great.

You can do it the quick and dirty way, open the form in SharePoint Designer, edit the form and delete the columns you don’t want to have in those forms. Well, there is a much better way of doing this. With Powershell.

It is easier, faster and more comfortable if you want to see the columns you added after that in the form. With SharePoint Designer your form has to be finished. If you add a new Column, that column will not be shown in the SharePoint Designer way. The Powershell way is the way to go here. How to do that? Follow the 6 steps and you are done!

1. First we are creating a list called “Projectlist”. If you have a list where you want to try it go directly to step 4.
Add an “Custom List”(1) (Pictures in German), give it a name (2) and add it (3).

HideFieldWithPowershell1_en

HideFieldWithPowershell2_en

2. Then we are adding two columns for testing purpose. The first is called “Description” and the second is called “Status”. This is the column we want to hide later on in the NewForm.
3. After adding those two columns your NewForm should look similar to this:

HideFieldWithPowershell3_en

4. Now go to your SharePoint BackendServer. With the following script the column “Status” will be hidden in the NewForm.

5. Open a SharePoint Management Shell as Administrator. You don’t need the SharePoint Management Shell because we are losing the Add-In, but just for learing purpose, do it.
6. Now fire the script, if you get an empty line, everything worked.

HideFieldWithPowershell5_en

7. Now if we create a new item, the column “Status” is hidden.

HideFieldWithPowershell6_en

Additional Information:

If you take the column from above:

$field.ShowInNewForm = $false

And change the $false into $true, the column will be visible again.
Same behaviour for the column:

#$field.ShowInEditForm = 0;

If you delete the leading “#” the code will be executed and refers to the EditForm. The values are the same as in the “ShowInNewForm” line.

Hope you liked this afraIT Shorty. If you want to stay tuned, follow me on Twitter or Facebook.

LEAVE A REPLY

Please enter your comment!
Please enter your name here