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:
- Type
- Name
- 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 (it seems to be case sensitive ?!). More properties are available into the MSDN documentation.
Hi! I ran into an issue. I discovered that the
TRUE/FALSE options are CaSe-SeNsItIvE!
It didn’t work for me until TRUE/FALSE was all capitals.
ShowInNewForm= »FALSE »
ShowInDisplayForm= »TRUE »
ShowInEditForm= »TRUE »
Really ?! THis is weird…. OK, I’m updating my post. Thanks.
Yeah, it is a very weird expectation!
This blogger also came across that issue in a different situation:
http://blog.krichie.com/2011/05/04/when-truetrue-and-when-not-to-listen-to-your-boss-while-dealing-with-content-types/