Reputation: 197
I have created a custom field type (derived from SPFieldText) and added a custom property "MyProperty". Now what I am looking for is, I need to use this field type in my Content Type feature.
How can I specity my custom property within a Content Type definition file, just like what we do with OOB field types?
I've seen a workaround here but it only solves only the problem of XSD validation. Site column is getting installed properly but the value that I specify in the feature is not set for the column after installing the feature.
Thank in advance
Arun
Upvotes: 5
Views: 3157
Reputation: 866
Something like this
<Field ID="{aec8cea1-d0df-49fc-baef-d356e58423f4}" Name="ClientWorkspace" DisplayName="$Resources:Nervogrid.Lauxtermann.Root,FieldWorkspaceDisplayName;" Type="ExtendedWorkspace" Group="$Resources:Nervogrid.Lauxtermann.Root,GroupLauxtermannFields;" AllowDuplicateValues="FALSE">
<Customization>
<ArrayOfProperty>
<Property>
<Name>SiteTemplates</Name>
<Value xmlns:q1="http://www.w3.org/2001/XMLSchema" p4:type="q1:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">;#12203;#</Value>
</Property>
<Property>
<Name>HideOnDisplayForm</Name>
<Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">$Resources:core,fld_no;</Value>
</Property>
<Property>
<Name>HideOnEditForm</Name>
<Value xmlns:q3="http://www.w3.org/2001/XMLSchema" p4:type="q3:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">$Resources:core,fld_yes;</Value>
</Property>
</ArrayOfProperty>
</Customization>
</Field>
Upvotes: 1
Reputation: 304
This worked for me
<Field ID="{EB4A62A3-5722-4D12-9AB8-BB36461D8E5D}" Type="MyCustomFieldType" Name="Website" DisplayName="Website" StaticName="Website" Required="true">
<Customization>
<ArrayOfProperty>
<Property>
<Name>MyFirstProperty</Name>
<Value>www.stackoverflow.com</Value>
</Property>
<Property>
<Name>MySecondProperty</Name>
<Value>stackoverflow</Value>
</Property>
</ArrayOfProperty>
</Customization>
</Field>
you can access the property in the validation class like this:
string myFieldValue = ((XmlNode[])this.GetCustomProperty("MyFirstProperty"))[0].Value;
Upvotes: 1
Reputation: 2364
Here is a thread on msdn forums that should answer your question. - http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/fb1cb936-3abb-48c2-8d19-49007688dc34/
Upvotes: 0