When I look in our DB we have 7,000 ++ custom fields. Out of that 7,000 we have 1,044 that are NOT HIDDEN.
Are there any known concerns with making all the custom fields that we don't THINK are being used as HIDDEN?
Is there a SQL Statement that I can use to determine when and if the custom field has ever been used and we have data associated with it on some order? (custom fields date back to 2015)
Looking to reuse the custom fields that we already have in place but want to better understand the current usage of the fields. I don't want to change the name.
Any advice or articles would be much appreciated.
As so far as SQL to modify custom field, I wouldn't because it is not safe. The two SQL tables with the data have a Watermark column and this is internal logic to Select - stay away. You can use SQL if you want to read information only (pf.CustomFieldDefinition and pf.CustomFieldDefinition).
As in all things Select, the preferred way is to use the appropriate manager, get the items and edit them, then save the changes. In this example, I'll invert the setting of the Hidden bit then save it. Using the CustomFieldDefinitions method on the ICustomFieldsManager you can get at all the CustomFields with many filtering options.
Code: Select all
ICustomFieldsManager cfMgr = ss.GetService<ICustomFieldsManager>(); ICustomFieldDefinition cfDef = cfMgr.CustomFieldDefinitions .Where(t => t.Name == "1031ExchangeAccommodatorNumber_SP#") .First(); bool hidden = !cfDef.Hidden; cfDef.Hidden = hidden; cfMgr.ApplyChanges(cfDef);