Wednesday, September 9, 2009

SharePoint - Hide Custom List Fields

From time to time you will need to hide fields on a custom list form page (NewForm.aspx, DisplayForm.aspx, or EditForm.aspx) This can be accomplished by using a Content Editor Web Part and so Javascript as show above.

In order to add a CEWP to the Custom List Form page, go to your list and click on the New button. You will see in the address bar that the address is 'http://sitename/list/listname/NewForm.aspx, add ?toolpaneview=2 on the end so that your url looks like this: 'http://sitename/list/listname/NewForm.aspx?toolpaneview=2

This will bring you to the edit mode of the page. Add a CEWP and the javascript as shown above. In the "hideFields" function replace the variable of "Title" with the display name of the field you wish to hide. If you have a requirement where you need to hide more than one field, simply copy the lines and paste the line as shown below:

function hideFields() {
var control = findacontrol("Title");"none";

control = findacontrol("Next Field to Hide");"none";

And there you have it, hiding fields on a custom list form page.

Note: Make sure the fields you are hiding are not required*

Hope this helps!!


No comments:

Post a Comment