In this article we will be seeing how to resolve the following error "Cannot change hidden attribute for this field". I have created a custom content type with one custom column. In the custom column I have given the hidden property to "false". Solution: Custom Content Type Elements.xml: Custom Site Column Elements.xml: When I was trying to change the hidden property through API with the following code using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint;
namespace SiteColumnModify { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://ukcbemtsekirk01:20/")) { using (SPWeb web = site.RootWeb) { SPField field = web.Fields["SiteColTest"]; field.Hidden = true; field.Update(); } } } } } I was getting the following error. How to resolve it: When you create a custom site column and if you want to change the hidden property make the "CanToggleHidden" property to true. This is read only property. Then try to change the hidden property it will be working fine.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: