At some point in your SharePoint development life time you will probably need to update the ShowInFileDlg attribute of a Site Column.
If you will try to do that by a feature and update the XML with new Field's attributes values, the changes will only take effect on new instances, and will not effect on exsisting ContentTypes or Lists that use these Site Columns.
Programmatically updating the Site Column and the Content Type, the changes will be deployed to the children as well.
Here is a generic method for updating any attribute of the Field element and forcing the changes to the Content Type and its children:
{
SPSite site = null;
SPWeb web = null;
try
{
using (site = new SPSite(siteCollectionURL))
{
using (web = site.OpenWeb())
{
SPField siteColumn = site.RootWeb.Fields.GetField(siteColumnName);
XmlDocument fieldSchemaXml = new XmlDocument();
fieldSchemaXml.LoadXml(siteColumn.SchemaXml);
XmlNode fieldXmlNode = fieldSchemaXml.SelectSingleNode("Field");
XmlAttribute attr = fieldXmlNode.Attributes[fieldAttributeName];
attr.InnerText = fieldAttributeValue; ;
siteColumn.SchemaXml = fieldXmlNode.OuterXml;
siteColumn.Update(true);
SPContentType contentType = site.RootWeb.ContentTypes[contentTypeName];
contentType.Update(true, false); //Updating the content type is important or the changes will not be reflected
}
}
}
finally
{
if (web != null)
web.Dispose();
if (site != null)
site.Dispose();
}
}