Sometimes when building SharePoint solutions or creating custom lists you want to hide some columns from the new or edit form. But the default new and edit form are automatically generating the form fields with all the columns that are created for the list.

This can be done in three different ways. The first way to do this is to use SharePoint Designer and make a custom form field, there are a couple of good articles about this (but you should be aware of that this could in some cases cause problems with e.g. attachments not working properly without extra coding). The second way, and the easiest way, is with content type as I will guide you through today. This might on the other hand be the least flexible. The last way is by using PowerShell which I will get back to later in the article.

Start by going to your list that you want to modifye the form fields on, this could be any kind of list or library. In the list go to List Settings and then click on the Advanced List settings.

What you first need to do is to allow management of Content Types. Click on Yes and then Ok.

allowmanagementofcontenttypes

You will then return back to the List Settings page which now looks a bit different. You will see a new section called Content Type. In my example I have used an Issue list so what I have is the Content Type Issue like shown in the picture below. 

 listsettingscontenttype

What you see now is a list of all the Site Columns that is connected to the Content Type Issue. This could have been any kind of Content Type, default or custom made that has default or custom made Site Columns.

contenttypecolumns

By clicking on any of the columns you are able to do some modifications to the column. In the Column Settings section you have three options. Required, Optional and Hidden. By Selecting Hidden the form field will not show up in forms. You should however note that this makes the form field hidden both in the NewForm.aspx and the EditForm.aspx forms.

changelistcontenttypecolumn

As I mentioned earlier there is a way to do this with PowerShell. By doing it programmatically you can part from the Content Type way just described decide which fields that should be visible individually between the NewForm.aspx and the EditForm.aspx. Since this solution is made by our PowerShell Guru I will simply link to his article and hope that this post was useful for you.



  1. [...] field. Mattias Karlsson, a friend of mine, describes a step-by-step on achieving this on his blog. In this Post, I’m going to describe how to do it through PowerShell. First make a connection [...]

  2. Deb Weathewax (Reply) on Friday 16, 2009

    Thank you, thank you, thank you. Worked perfectly!!!

  3. BostonMike (Reply) on Friday 16, 2009

    This works great but I have a situation where I need to hide the Name field in the EditForm in a document library. We dont want users to change a file name once it has been uploaded. Because the Name field is a required field and is part of the parent Document content type it has no way to get to the options screen to choose to hide it. Any suggestions here?

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Hi,

      I did some consulting with Niklas Goude and we found out that it works if we do it with PowerShell (maybe this will be a separate post later on).

      Use the following code in PowerShell

      $SPSite = New-Object Microsoft.SHarePoint.SPSite(“http://yoursite”)

      $OpenWeb = $SPSite.OpenWeb(“/your site”)

      $List = $OpenWeb.Lists["Name of your list"]

      $UserAgent = $List.Fields["Name of your column"]

      $UserAgent.ReadOnlyField = $True

      $UserAgent.Update()

      This will make the field to now even show up in the edit form but you are able to use it in views etc.

      Hope this works for you

  4. BostonMike (Reply) on Friday 16, 2009

    It sure did work…like a charm. thank you very much!

  5. Radha (Reply) on Friday 16, 2009

    Vat if I want to hide a field Content Type from :EditPage.aspx page
    If I attach a folder content type to a folder and when I say new item I get to select a content type option, provided I want to freeze it to my own created folder content type or just remove the content type field permanantly from the page .
    Is der any way to solve it?

  6. Elliot (Reply) on Friday 16, 2009

    This is excellent stuff – thanks for posting.

    A question I have is how to use this feature (or something similar) to display different fields on different Edit pages? What I am trying to do is provide various ways of editing the same list where different edit pages present the user with different data fields – but all are from the same list. For example, my list contains fields 1 through 10 and I want user A to only edit fields 1-3 and user B to only edit fields 4-10.

    The flexibility I have is limited as unfortunately SharePoint Designer is not available at my company (I am just a user of an enterprise level implementation).

    I think this may be possible via Data-Sheet views, but I’m a little reluctant to use Data-Sheet views as I’ve had issues with them in the past.

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Hi Elliot,

      Unfortunately there is now way to handle this out of the box. The most solid way would be to build a web part that has integrated support for checking what fields the user should have. You could then create different SharePoint groups to put the users in and check towards, however this needs some custom coding.

      The datasheet views does not give you a full proof way lock down the fields for some users. The same goes for if you create multiple edit form fields and then with PowerShell make the different fields hidden and direct the users to the different forms.
      Since it seems like you do not have admin rights, unfortunately none of the above suggestions are an option for you. I would recommend talking to you IT department and check the opportunities to create a custom edit form.

  7. shafaqat (Reply) on Friday 16, 2009

    hi
    i want to show and hide fields depending upon the user group, if a user is a part of Group A, he should see some fields but if a user is not part of Group A, he should not see some specific fields of a List. i am not using custom list, i am using simple list of type “tasks”
    is it possible to achieve this?

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Hi,
      This is a common question and something many organizations have on their wish list for Office 14. Unfortunately it’s not possible out-of-box with either WSS 3.0 or Moss. To be able to do this you need to create some kind of web part that render the form fields for you and where you can connect the field towards a group. That web part will then replace the one uses in the newform.aspx and editform.aspx. I have not seen any free web part like this but I think that we at Zipper has made something similar in some project so if you want I can get back to you and we can see if we can find some kind of arrangement.

  8. shafaqat (Reply) on Friday 16, 2009

    hi
    thanx for your timely reply.
    check out this solution
    http://www.sharepointboost.com/columnpermission.html
    but expensive.

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Looks solid. Something to extend the article with maybe. Thanks

  9. shafaqat (Reply) on Friday 16, 2009

    i am looking closely that how user or group could be bound to list fields, if you find something related to it, please share.

  10. reddy (Reply) on Friday 16, 2009

    I have similar situation on the column level permission

    I want a field in the form to be visible based on the selection in other fields

    i.e field 1 drop down list with options -( option 1, option2)
    field 2 drop down with options ( selection 1, selection 2)

    field 3 is supposed to be shown only when some one selects field1-option 2 & field2-selection2

    is this possible through custom code or any validators in sharepoint designer .

    Please help

  11. Litehouse (Reply) on Friday 16, 2009

    Awesome!!! This was exactly what I needed, I have been looking for this solution forever.

  12. Joshua Francis (Reply) on Friday 16, 2009

    Hello,
    I have a SharePoint custom list with several fields. It is an action log tracking system. I want the admin. to enter action items and assign to the respective users to update status and comments of the item. The first part works well out of the box, but I want when the specific user opens up the form to edit their items, only the status and remarks field are editable. All other fields are ‘read only’. Further to this, the admin can open an edit form and see all fields as editable and not just status and remarks. How can this be accomplished? Thanks in advance.

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Hi,

      There is unfortunately no out of the box features to use to accomplish this very common request, you are not alone :) It can however be made through custom coding. I thing that came to my mind right now and that I have not tested myself is if it would be possible with javascript to put the fields in read only through SharePoint designer. This step I’m quite sure works if you just know the names of the fields. Next step would be to wrap this into some kind of control looking up the users. As I said, I have not tested thism don’t know if it works and should be seen as a fairly “dirty” solution. I’ll see if I can find the time to investigate my thoughts further and if you find something out please let me know.
      /Mattias

  13. James Scrivener (Reply) on Friday 16, 2009

    Perfect post exactly what I needed.

    It was suggested to me to use some javascript in in the page but this is so much easier!

  14. maajka (Reply) on Friday 16, 2009

    wow this is amazing, I have been looking for ways to get this done for 6 months now and have been to alot of different forums and help sites but NONE offered a simple solution like this and most relied on scripts that hide fields…I don’t understand why you seem to be the only person on the internet to offer this easy solution, THANK YOU!

  15. Bob Cedric (Reply) on Friday 16, 2009

    There another great solution for it.
    we are using Infowise Smart List Pro which can run on both WSS 3.0 and MOSS 2007 (Has a SharePoint 2010 version also).
    Smart List Pro extend the SharePoint lists & document libraries, and gives them abilities like – field/column permissions based on rules , default values, view permissions, tabbed interface and much more.

    check it out- http://www.infowisesolutions.com/product.aspx?id=SmartListPro

  16. [...] Hide form fields in SharePoint | My SharePoint of View – Sometimes when building SharePoint solutions or creating custom lists you want to hide some columns from the new or edit form. But the default new and edit form are automatically generating the form fields with all the columns that are created for the list. [...]

  17. Stefanie (Reply) on Friday 16, 2009

    I am using the FAB 40 Attendance template from Microsoft and wanted to hide some of the custom columns I’m getting an error when I attempt to edit the content types:

    “Folders are not allowed for this list template. ”

    What Can I do?

  18. L Johnson (Reply) on Friday 16, 2009

    InfoPath might be an option for scenario based edit forms…

  19. Samir Warsi (Reply) on Friday 16, 2009

    Hey Mattias,
    I tried your method to hide the fields on NewItem.aspx, but its not working.

    In my case I have cutomized the form (newItem.aspx) using sharePoint Designer. I want to know because of being customised form its not working?

    If yes then how can I hide few fields on the form?

    Please help
    Thanks in advance

  20. James Scrivener (Reply) on Friday 16, 2009

    Hi Samir,

    I think it may be because you have customised your page that the hidden permission is not filtering down.

    You can insert a bit of javascript at the top of the page to hide the requried columns…

    For example, if you add this piece of javascript under

    _spBodyOnLoadFunctionNames.push(“hideFields”);

    function HideSharePointControl(FieldName)
    {
    var control = findacontrol(FieldName);
    control.parentNode.parentNode.style.display=”none”;
    }

    function findacontrol(FieldName) {

    var arr = document.getElementsByTagName(“!”);
    // get all comments
    for (var i=0;i 0)
    { return arr[i]; }
    }
    }

    function hideFields() {
    //Fields to toggle
    var grantedFields = ["Field Name 1", "Field Name 2"];

    var len = grantedFields.length;
    var control;

    for(var i=0; i<len; i++)
    {
    HideSharePointControl(grantedFields[i]);
    }
    }

    Where grantedFields is displayed you can list the field names. I think I've changed it enough for it just to hide all (I had to remove some logic my solution used, but i hope you get the idea.

    Hope this helps in some way.

    James.

  21. James Scrivener (Reply) on Friday 16, 2009

    Don’t forget to put the javascript in a tag!

  22. James Scrivener (Reply) on Friday 16, 2009

    I am really sorry for this, it has missed out some of the code for the findacontrol function…

    function findacontrol(FieldName) {

    var arr = document.getElementsByTagName(“!”);
    // get all comments
    for (var i=0;i 0)
    { return arr[i]; }
    }
    }

  23. James Scrivener (Reply) on Friday 16, 2009

    Nope it keeps removing it, if you would like the code listing please give me your email address and I will send it over!

    James

  24. Saravana Gandhi (Reply) on Friday 16, 2009

    Thanks, worked as i expected :)

  25. compumak (Reply) on Friday 16, 2009

    thanks for this nice article

    I wanted to ask about hiding some Columns from some users (such as visitors or other groups )

    example : when a client comes to me I write down all his info. including his email, P.H ,how much he is going to pay etc…

    so I wanna to hide this information from people who is suppose to do the task .

    Please help me to do this .
    Note : I am using sharepoint foundation not server enterprise .

    Thank you very much .

    • Mattias Karlsson (Reply) on Friday 16, 2009

      Hi,

      This is unfortunately not possible either in 2007 or 2010. To be able to do this you will need to make some custom development. I have not done it myself but I have been in a project were we did exactly what you are asking of and my understanding is that it’s a fairly easy task for a developer to do.

      /Mattias

  26. compumak (Reply) on Friday 16, 2009

    I forgot to say , I wanna hide these columns from some groups and show them to others .

  27. Bob's Your Uncle (Reply) on Friday 16, 2009

    Thank you! Now I can modify my form with new fields.

  28. James Scrivener (Reply) on Friday 16, 2009

    Hi,

    What I’ve done in the past is use SharePoint designer and then add a C# script section that uses the SharePoint API finds out the details I require and then adds the data to some hidden HTML fields.

    Then I add a javascript script section to the page to then hide the fields according to the values in the hidden fields.

    You could apply this in someway to your problem compumak?

    James.

  29. Compumak (Reply) on Friday 16, 2009

    Thank you very much Mattias Karlsson and James Scrivener.

    James Scrivener Could you give explain steps for doing this ?

    but after awhile I got another idea , that idea was to create a list which is Responsible for client information (name,paid money,tell and ect…) and it should be linked to a number .
    that number when you write it into a task it should automaticly show and write what was in the main form (which is the customar form) except some fields (such as phone and fees)