I've created a custom field type called CompanyRule.
I've created a content type call RulesCT with four site columns that are of type CompanyRule. Initially I can give and update the values of the the custom parameters without any problem.
I created a list that used the RulesCT content type. Now when I update the custom parameters while "Update all list columns based on this site column?" is set to yes, it blanks out all of the custom parameters. If I set it to no, it works as expected. Below are two functions that seem to be where the error occurs but I can't tell what it might be. Any help would be appreciated.
//Field is updated
public override void OnUpdated()
{
SPAddFieldOptions op = SPAddFieldOptions.Default;
String addFieldOptionPropertyValue = this.GetProperty("AddFieldOption");
if (!String.IsNullOrEmpty(addFieldOptionPropertyValue))
{
op = (SPAddFieldOptions)Enum.Parse(typeof(SPAddFieldOptions), this.GetProperty("AddFieldOption"), true);
}
if (!this.savingSchemaXml)
{
this.savingSchemaXml = true;
base.SchemaXml = this.CreateOrUpdateFieldSchemaXml(op);
this.CleanThreadLocalStorage();
}
}
//
private string CreateOrUpdateFieldSchemaXml(SPAddFieldOptions op)
{
XElement schemaXmlElement = XElement.Parse(this.SchemaXml);
schemaXmlElement.SetAttributeValue("CFDCTMID", this.GetPropertyFromThread<string>("CFDCTMID"));
schemaXmlElement.SetAttributeValue("CFStatus", this.GetPropertyFromThread<string>("CFStatus"));
schemaXmlElement.SetAttributeValue("CFType", this.GetPropertyFromThread<string>("CFType"));
schemaXmlElement.SetAttributeValue("CFDefaultValue", this.GetPropertyFromThread<string>("CFDefaultValue"));
schemaXmlElement.SetAttributeValue("CFDataSource", this.GetPropertyFromThread<string>("CFDataSource"));
schemaXmlElement.SetAttributeValue("CFDataTable", this.GetPropertyFromThread<string>("CFDataTable"));
schemaXmlElement.SetAttributeValue("CFLabCol", this.GetPropertyFromThread<string>("CFLabCol"));
schemaXmlElement.SetAttributeValue("CFValCol", this.GetPropertyFromThread<string>("CFValCol"));
schemaXmlElement.SetAttributeValue("CFParentControl", this.GetPropertyFromThread<string>("CFParentControl"));
schemaXmlElement.SetAttributeValue("CFParentChangeQuery", this.GetPropertyFromThread<string>("CFParentChangeQuery"));
schemaXmlElement.SetAttributeValue("CFChildControl", this.GetPropertyFromThread<string>("CFChildControl"));
schemaXmlElement.SetAttributeValue("CFChildChangeQuery", this.GetPropertyFromThread<string>("CFChildChangeQuery"));
schemaXmlElement.SetAttributeValue("CFEventTriggerGroup", this.GetPropertyFromThread<string>("CFEventTriggerGroup"));
schemaXmlElement.SetAttributeValue("CFEventListenerGroup", this.GetPropertyFromThread<string>("CFEventListenerGroup"));
schemaXmlElement.SetAttributeValue("CFEventListenerAction", this.GetPropertyFromThread<string>("CFEventListenerAction"));
schemaXmlElement.SetAttributeValue("CFSearchOrder", this.GetPropertyFromThread<string>("CFSearchOrder"));
schemaXmlElement.SetAttributeValue("CFUploadOrder", this.GetPropertyFromThread<string>("CFUploadOrder"));
//TRY / CATCH in place because you can not unbox a generic of type bool when it is null - apparently
try
{ schemaXmlElement.SetAttributeValue("CFSearchVisible", this.GetPropertyFromThread<bool>("CFSearchVisible")); }
catch
{ schemaXmlElement.SetAttributeValue("CFSearchVisible", this.GetPropertyFromThread<string>("CFSearchVisible")); }
try
{ schemaXmlElement.SetAttributeValue("CFUploadVisible", this.GetPropertyFromThread<bool>("CFUploadVisible")); }
catch
{ schemaXmlElement.SetAttributeValue("CFUploadVisible", this.GetPropertyFromThread<string>("CFUploadVisible")); }
schemaXmlElement.SetAttributeValue("AddFieldOption", op.ToString());
return (schemaXmlElement.ToString());
}