1

I am creating a field through the following xml:

<Field
    Name="FieldName"
    StaticName="FieldName"
    DisplayName="FieldName"
    Required="FALSE"
    Hidden="FALSE" 
    ID="{12345678-1234-4321-1234-123456789012}"
    Group="FieldGroup"
    Type="Choice"
    Format="Dropdown"
    SourceID="http://schemas.name.nl/">
        <Default>FirstChoice</Default>
        <CHOICES>
          <CHOICE>FirstChoice</CHOICE>
          <CHOICE>SecondChoice</CHOICE>
          <CHOICE>ThirdChoice</CHOICE>
        </CHOICES>    
</Field>

I am using the following function for this:

CSOM.Field field = web.CreateField(Xml);

This all goes correctly, however the default value is not fully coming through. If I create a listitem with this field on it, the value is empty at first, while I should have expected the default value here.

In the list settings the default value is set correctly as FirstChoice. But only when I open the list settings and press okay (While not changing anything!) When I do this and then create another list item, the value is set with the default value right away.

Can anyone explain where this behavior is coming from and how I can fix this?

1

Try with this:

<Field 
    Name="FieldName"
    DisplayName="FieldName"
    Required="FALSE"
    Hidden="FALSE" 
    ID="{12345678-1234-4321-1234-123456789012}"
    Group="FieldGroup"
    Type="Choice">
        <CHOICES>
          <CHOICE>FirstChoice</CHOICE>
          <CHOICE>SecondChoice</CHOICE>
          <CHOICE>ThirdChoice</CHOICE>
        </CHOICES>    
  <Default>FirstChoice</Default>
</Field>
  • That worked for me, putting it outside of the <CHOICES> tag i find it so hard to get documentation for this stuff! – platinums Oct 9 '19 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.