views:

126

answers:

1

i create a content type using feature as below

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
  <Field ID ="{4C939423-2090-413d-B241-724D9B66F74B}"
         Name="VersionNumer"
         DisplayName="Version Number"
         Type="Text"
         Required="TRUE"
         Group="CT" >
    <Default>0</Default>
  </Field>


  <Field ID ="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}"
         Name="DocumentType"
         DisplayName="Document Type"
         Type="Choice"
         Required="TRUE"
         Group="CT">
    <Default>Other</Default>

    <CHOICES>
      <CHOICE>Document</CHOICE>
      <CHOICE>Excel</CHOICE>
      <CHOICE>PowerPoint</CHOICE>
      <CHOICE>Other</CHOICE>
    </CHOICES>
  </Field>

  <ContentType ID="0x0101000728167cd9c94899925ba69c4af6743e"
               Name="myCT"
               Group="myCT"
               Description="myCT"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{4C939423-2090-413d-B241-724D9B66F74B}" Name="VersionNumber" DisplayName="Version Number" Required="TRUE" />
      <FieldRef ID="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}" Name="DocumentType" DisplayName="Document Type" Required="TRUE"  />      
    </FieldRefs>  
  </ContentType>
</Elements>

How can i set default value for VersionNumer is 0 and default value for DocumentType is Other? I used default tag but it was not efficent.

And another question, how to force user to input VersionNumer and DocumentType. I used atrtibute required="true" but it was not successful. Thanks in advance.

+1  A: 

I've tried this in my environment, it works perfectly. I copy 'n' pasted the contents of elements.xml and didn't make a single modification.

Try this:

  • Delete your existing site columns and content type (in that order)
  • Deactivate your feature
  • IISRESET
  • Activate your feature again and check if the default values are ok, they should be
Tom Vervoort
it worked. may be share point got a problem. thank you.
Wayne
This may be the cause... when you update a feature that contains site columns and content types, you always need to deactivate the feature, delete the site columns and content types, uninstall the feature, do an iisreset, install the feature again and activate the feature again. Maybe at one point, you forgot to delete the site columns and content types after modifying your feature, and you just deactivated and reactivated it.
Tom Vervoort