Field

Field

Add Field to site collection (Site Columns):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<Site Url="{url}" Title="{title}" Template="STS#3" LCID="1033" OwnerLogin="{owner}" UserCodeQuota="0" StorageQuota="0">
    <RootWeb Url="{url}" Title="{title}" Description="{description}" Template="STS#3" LCID="1033">
        <Fields>
            <Field Name="ProjectSiteUrl" DisplayName="Project Site Url" >
                <![CDATA[<Field ID="{0FF1B04D-C526-4803-8D19-35E3CA81F04F}" 
                    Name="ProjectSiteUrl" 
                    StaticName="ProjectSiteUrl" 
                    DisplayName="Project Site Url" 
                    Type="Text" 
                    Required="TRUE" 
                    Group="Project Center" 
                    EnforceUniqueValues="TRUE" 
                    Indexed="TRUE" 
                    Description="The last part of the URL for this Project Site" 
                    MaxLength="128"/>
                ]]>
            </Field>
        </Fields>
    </RootWeb>
</Site>

Add Field to list:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<Lists>
    <List Url="Bibliotheek" TemplateType="101" TemplateFeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" ContentTypesEnabled="True" Title="Bibliotheek">
        <Fields>
            <Field Name="ProjectSiteUrl" DisplayName="Project Site Url" >
                <![CDATA[<Field ID="{0FF1B04D-C526-4803-8D19-35E3CA81F04F}" 
                    Name="ProjectSiteUrl" 
                    StaticName="ProjectSiteUrl" 
                    DisplayName="Project Site Url" 
                    Type="Text" 
                    Required="TRUE" 
                    Group="Project Center" 
                    EnforceUniqueValues="TRUE" 
                    Indexed="TRUE" 
                    Description="The last part of the URL for this Project Site" 
                    MaxLength="128"/>
                ]]>
            </Field>
        </Fields>
    </List>
</Lists>

Variations

The Field entity has several variations.

FieldCalculated

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<FieldCalculated Name="TestCalculated" DisplayName="TestCalculated" DateFormat="DateTime" OutputType="DateTime" Formula="=DATE(YEAR(Modified),MONTH(Modified),DAY(Modified))">
    <![CDATA[
    <Field ID="{01854464-EABC-4726-A517-397A4EA224C2}" 
        Name="TestCalculated" 
        StaticName="TestCalculated" 
        DisplayName="TestCalculated" 
        Group="Test New Fields" 
        Type="Calculated" 
        Format="DateOnly" 
        ResultType="DateTime">
        <Formula>=DATE(YEAR(Created),MONTH(Created),DAY(Created))</Formula>
        <Default></Default>
        <FieldRefs>
            <FieldRef Name="Created" />
        </FieldRefs>
    </Field>]]>
</FieldCalculated>

FieldChoice

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<FieldChoice Name="TestChoice" DisplayName="TestChoice" EditFormat="Dropdown" FillInChoice="TRUE">
    <Choices>
        <Choice>Blauw</Choice>
        <Choice>Groen</Choice>
        <Choice>Wit</Choice>
        <Choice>Rood</Choice>
    </Choices>
    <![CDATA[<Field ID="{E1C05F69-973E-46e3-B52E-625FB267652E}"
        Name="TestChoice"
        DisplayName="TestChoice"
        Group="Test New Fields"
        Type="Choice"
        Description="A radio button choice field."
        Required="FALSE"            
        Format="RadioButtons">
        <CHOICES>
        <CHOICE>Blue</CHOICE>
        <CHOICE>Green</CHOICE>
        <CHOICE>White</CHOICE>
        <CHOICE>Red</CHOICE>
        </CHOICES>
    </Field>]]>
</FieldChoice>

FieldCurrency

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<FieldCurrency Name="TestCurrency" DisplayName="TestCurrency" CurrencyLocaleId="1033">
    <![CDATA[<Field ID="{9B0438B3-16A9-4385-8426-D56C92336129}"
        Name="TestCurrency"
        DisplayName="TestCurrencye"       
        Group="Test New Fields"
        Type="Currency"
        Description="A custom currency field using the LCID of 1043 for the Dutch locale."
        Required="FALSE"             
        LCID="1043">
    </Field>]]>
</FieldCurrency>

FieldDateTime

1
2
3
4
<FieldDateTime Id="3d9cc5d1-9705-4bf0-9011-f250e178355d" Name="TestDateTime" DateTimeCalendarType="Gregorian" DisplayFormat="DateOnly" >
<![CDATA[<Field Type="DateTime" DisplayName="TestDateTime" EnforceUniqueValues="FALSE" Required="TRUE" Hidden="FALSE" ReadOnly="FALSE" 
        CanToggleHidden="FALSE" ID="{3d9cc5d1-9705-4bf0-9011-f250e178355d}" Name="TestDateTime" StaticName="TestDateTime" Format="DateOnly" />]]>
</FieldDateTime>

FieldLookup

1
2
3
4
<FieldLookup Name="TestLookup" DisplayName="TestLookup" Id="7d59b4c7-3963-48db-bcc1-c8ef4293b53a" 
             AllowMultipleValues="false" LookupField="Title" LookupList="Documents" 
             LookupWeb="{url}" Required="false">
</FieldLookup>

FieldMultiChoice

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<FieldMultiChoice Name="TestMultiChoice" DisplayName="TestMultiChoice" FillInChoice="TRUE">
    <Choices>
        <Choice>Noord</Choice>
        <Choice>Zuid</Choice>
        <Choice>Oost</Choice>
        <Choice>West</Choice>
    </Choices>
    <![CDATA[<Field ID="{830D342E-E41B-4f00-8285-7B2A33BD31B6}"
        Name="TestMultiChoice"
        DisplayName="Multi-Choice with No Edit"
        Group="Test New Fields"
        Type="MultiChoice"
        Description="A multi-choice field with FillInChoice set to FALSE."
        FillInChoice="FALSE"
        Required="FALSE">
        <CHOICES>
        <CHOICE>North</CHOICE>
        <CHOICE>South</CHOICE>
        <CHOICE>East</CHOICE>
        <CHOICE>West</CHOICE>
        </CHOICES>
        <Default>North</Default>
    </Field>]]>
</FieldMultiChoice>

FieldMultiLineText

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<FieldMultiLineText Name="TestMultiLine" DisplayName="TestMultiLine" NumberOfLines="4" AllowHyperlink="TRUE" AppendOnly="TRUE" RichText="TRUE">
    <![CDATA[<Field ID="{2ae59f08-0fb0-4a9c-8a31-a180161b1029}" 
        StaticName="TestMultiLine" 
        Name="TestMultiLine"
        DisplayName="TestMultiLine"
        Type="Note"
        RichText="FALSE"
        NumLines="6"
        Group="Test New Fields"/>]]>
</FieldMultiLineText>

FieldNumber

1
2
3
4
5
6
7
8
<FieldNumber Name="TestNumber" DisplayName="TestNumber" MinimumValue="1" MaximumValue="100" ShowAsPercentage="TRUE">
    <![CDATA[<Field ID="{BAC1B985-2AE5-4a3b-A163-09FC4BE62E0B}"
        Name="TestNumber"
        DisplayName="TestNumber"
        Group="Test New Fields"
        Type="Number">
    </Field>]]>
</FieldNumber>

FieldRatingScale

1
2
3
4
5
6
<FieldRatingScale Name="TestRating" DisplayName="TestRating" GridEndNumber="3" GridNAOptionText="niets" GridTextRangeAverage="Gemiddeld" GridStartNumber="0" GridTextRangeHigh="Hoog" GridTextRangeLow="Laag">
    <Choices>
        <Choice>Keuze</Choice>
    </Choices>
    <![CDATA[<Field Type="GridChoice" DisplayName="TestRating" Group="Test New Fields" Required="FALSE" GridStartNum="1" GridEndNum="5" GridTxtRng1="Low" GridTxtRng2="Average" GridTxtRng3="High" GridNATxt="N/A" ID="{5259c17a-9260-4857-8594-f7dc28281763}" StaticName="TestRating" Name="TestRating"><CHOICES><CHOICE>Rating</CHOICE></CHOICES></Field>]]>
</FieldRatingScale>

FieldText

1
2
3
<FieldText Name="TestText" DisplayName="TestText" MaxLength="20">
    <![CDATA[<Field ID="{621DB817-B98D-462A-A7AC-5D4BEF6BEE36}" Name="TestText" StaticName="TestText" DisplayName="TestText" Type="Text" Group="Test New Fields"/>]]>
</FieldText>

FieldUrl

1
2
3
<FieldUrl Name="TestUrlField" DisplayName="TestUrlField" Id="F4AF6598-05F1-42FF-A3F1-3E3CA3871111" TypeAsString="URL" DisplayFormat="Hyperlink">
    <![CDATA[<Field ID="{F4AF6598-05F1-42FF-A3F1-3E3CA3871111}" Name="TestUrlField" DisplayName="TestUrlField" Group="Test New Fields" Type="URL" Format="Hyperlink"/>]]>
</FieldUrl>

FieldUser

1
2
3
4
<FieldUser Id="ac3442ec-6d96-4157-aac6-b35dc00a0540" Name="Behandelaar">
    <![CDATA[<Field Type="User" StaticName="Behandelaar" Name="Behandelaar" DisplayName="Behandelaar" List="UserInfo" Required="FALSE" 
      EnforceUniqueValues="FALSE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" Group="PD Basiskolommen" ID="{ac3442ec-6d96-4157-aac6-b35dc00a0540}"/>]]>
</FieldUser>