Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a list, and all I am trying to do is hide an column for when a user creates a new item, but allow the column to be shown in the edit item page. Currently if I hide a column it is hidden in both fields. Thanks!

share|improve this question
add comment

5 Answers 5

You can define this when you add a column in CAML via the ShowInNewForm and ShowInEditForm properties. You can find all the valid properties in the article Field Element (List)

Alternatively, you can set these values using the object model (likely Powershell, since this is a one off run). The properties of the SPField object are the same (ShowInNewForm / ShowInEditForm).

share|improve this answer
    
Hi, so I do not have access to the server (I'm an intern with only front end access to our sharepoint with developer access), so how would I go about editing the CAML? Sorry, I am extremely new to sharepoint –  TrevorTheIntern Jun 20 at 15:48
    
You can't. That's only for new columns. If it's already deployed you'll need to set the property of the SPField object and update the column. There's a proposed answer below using JavaScript as well, though I've never tried that way so YMMV. –  RJ Cuthbertson Jun 20 at 15:53
add comment

You can also apply jquery to hide the column.

i.e. $("input[title='Title']").closest('tr').hide();

you have to add content editor web part in newform.aspx of list to apply jquery.

share|improve this answer
    
Hi, so I am trying to do this, but when I add that snippet to the content editor web part, it doesn't do anything (I changed the 'Title' to the name of one of the fields I want to find). I was able to get some javascript to run from that field, (made an alert box pop up) so it's just an issue of getting this to work. I made sure to import jquery before hand –  TrevorTheIntern Jun 20 at 15:47
    
yes. you need to add jquery reference before if you want to use above code. the best you can do is write this code: <script src="../../site assets/jquery1.8.2.min.js"></script> <script> $("input[title='Title']").closest('tr').hide(); </script> save the file with .js extension. upload in any document library and refer this file in content editor web part. –  SSS Jun 21 at 17:15
add comment

The answer from @RJ Cuthbertson is very interesting! So I digged it and I wrote a blog post about that.

I reproduce here what I wrote in my blog:

With the Sharepoint WebServices it’s possible to hide a field into the NewForm, the Editform and/or the DispForm. You’ll need to use JavaScript with jQuery and SPServices. It’s the UpdateList service that will do the trick.

Once you have loaded the both librairies you can use the below code:

var fieldsToUpdate = '<Fields>';
fieldsToUpdate += '<Method ID="1"><Field Type="Text" Name="My_x0020_Field" DisplayName="My Field" ShowInDisplayForm="False" ShowInEditForm="False" ShowInNewForm="False"></Field></Method>';
fieldsToUpdate += '</Fields>';

$().SPServices({
  operation: "UpdateList",
  listName: "Name of the list",
  listProperties:"",
  updateFields: fieldsToUpdate,
  newFields: "",
  deleteFields: "",
  listVersion: "",
  completefunc: function (xData, Status){}
});

As explained into this Stackoverflow’s question you must provide a minimum of three mandatory properties, and in this order:

  1. Type
  2. Name
  3. DisplayName

The Type must reflect the type of your field. This information is available into the MSDN documentation. The most common values should be Boolean | Calculated | Choice | Currency | DateTime | Integer | Lookup | LookupMulti | MultiChoice | Number | Text | User | UserMulti.

The Name is the internal name (usually the spaces are replaced with « x0020 »).

And for each form (ShowInDisplayForm | ShowInEditForm | ShowInNewForm) you can set them to True or False. More properties are available into the MSDN documentation.

share|improve this answer
add comment

In the list settings you can select the content types as on. then select the item content type and hide the column

share|improve this answer
    
OP wants to hide a specific column, not a content type –  Robert Lindgren Jul 11 at 11:31
add comment

Maybe I am missing something, but these answers are way more complicated than they need to be.

Just make a custom NewForm.aspx in SharePoint designer, edit it, and delete that field. If you get an error for deleting some mandatory field. Just do inline css style="display:none" to hide the field, though do make sure it is getting a default value. Then set that newform as the default.

It should take you less than two minutes this, and you don't need jQuery, CAML, powershell, whatever...

share|improve this answer
    
I agree that this is a much better answer than using jQuery in a Content Editor Web Part, but if you make a custom form and down the road additional columns are added to the list, won't you have to modify your form as well? –  RJ Cuthbertson Jul 11 at 14:32
    
Using the object model allows SharePoint to manage this field's display without having to move away from using the default form. And I don't think that any of these answers would take more or less time than each other. They're all relatively quick fixes if you know what you're doing. –  RJ Cuthbertson Jul 11 at 14:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.