Home
> Work > Programmatically setting a field to hidden within a Content Type #SharePoint #SP2010 #in
Programmatically setting a field to hidden within a Content Type #SharePoint #SP2010 #in
At a client recently, my development colleague was struggling to find out how to set a field attached to a custom Content Type in a list to be hidden to aid in document management (so it is not shown in the Document Properties panel in Microsoft Word).
The following post seemed to suggest an unofficial way:
However, we try to keep things in a supported model if possible.
Through further looking he came across the following property:
- After further playing in code, he managed to crack it with the “.hidden” method.
- Code Example:
This code will set the Hidden flag (same as you can through the UI) against the document library. The above iterates through a List of strings which contains the fields i want to hide.
NB: Please not that this works because we are using our own content type attached to the library.
Categories: Work
C#, MOSS 2007, SharePoint 2010, SPContentType, SPF 2010, WSS 3.0
Cool. Seems a bit quicker than the unsupported toggling CanToggleHidden internal property w/ reflection at any rate!