Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Custom Properties for a custom field type within a content type feature

Tags:

sharepoint

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

like image 387
Arun Avatar asked Nov 05 '22 07:11

Arun


2 Answers

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>
like image 38
Maks Matsveyeu Avatar answered Nov 09 '22 17:11

Maks Matsveyeu


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;
like image 166
domueni Avatar answered Nov 09 '22 15:11

domueni