سؤال

I've to create with Visual Studio 2012 a Document Library for SharePoint 2013. I've started defining the unique field in an empty element:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field  ID="{cf3eb7b7-3621-4b3d-b6a8-a01c4a0dbaf1}"
          Name="DUMMY"
          StaticName="DUMMY"
          DisplayName="DUMMY"
          Type="Choice"
          Format="RadioButtons"
          FillInChoice="FALSE"
          SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"
          Required="TRUE"
          Group="DUMMY">
    <CHOICES>
      <CHOICE>DUMMY</CHOICE>
      <CHOICE>DUMMY</CHOICE>
    </CHOICES>
  </Field>
</Elements>

After the content type:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Item (0x01) -->
  <ContentType ID="0x010097577133AD4B429E8EEF2927AD9EEB04" 
               Name="DUMMY" 
               Group="DUMMY" 
               Description="DUMMY" 
               Inherits="FALSE" 
               Version="0" 
               ReadOnly="FALSE">
    <FieldRefs>
      <FieldRef ID="{CF3EB7B7-3621-4B3D-B6A8-A01C4A0DBAF1}" 
                DisplayName="DUMMY" 
                Required="TRUE" 
                Name="DUMMY" />
    </FieldRefs>
  </ContentType>
</Elements>

The Document Library definition:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListTemplate
        Name="DUMMY"
        Type="10000"
        BaseType="1"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="110"
        DisplayName="DUMMY"
        Description=""
        Image="/_layouts/15/images/itdl.png"
        DocumentTemplate="121"/>
</Elements>

And the Document Library instance:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance
    Title="DUMMY"
    OnQuickLaunch="TRUE"
    TemplateType="10000"
    Url="Lists/DUMMY"
    Description="" />
 </Elements>

The Document Library has been correctly created but when I upload a file my custom field has an empty dropdown. I've also done what I need by browser and downloaded the xml from SharePoint, searched for the custom field definition and pasted in my project but it didn't work anyway...

Thank you

هل كانت مفيدة؟

المحلول

I found the solution for my issue. I've to update the document library definition Schema.xml too.

Something like this

  <Field ID="{F9BD72AE-1DB2-4D10-AF6D-A2F12B8D0408}"
         Name="DUMMY"
         DisplayName="DUMMY"
         Type="Choice"
         Format="RadioButtons"
         Required="TRUE"
         Group="DUMMY">
    <Default>N</Default>
    <CHOICES>
      <CHOICE Value="DUMMY">DUMMY</CHOICE>
      <CHOICE Value="DUMMY">DUMMY</CHOICE>
    </CHOICES>
  </Field>
</Fields>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top