This is a handy trick. When you create a list definition, sometimes you want to set default values, as easy as using the element <Default> and insert the default data between <Default> (ie: <Default>#FFEBCD</Default> ).
Have a look to this example coming from my Schema.xml:
I have introduced “#FFEBCD” as default value for the border color, I have also set the “alphabottom” value to 1.0.<Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B99}" Name="alphatop" DisplayName="alphatop" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>1.0</Default></Field><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B00}" Name="alphabottom" DisplayName="alphabottom" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>1.0</Default></Field><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B01}" Name="overlayimagebottomenabled" DisplayName="overlayimagebottomenabled" Type="Boolean" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B02}" Name="overlaycolorbottom" DisplayName="overlaycolorbottom" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B03}" Name="bordercolor" DisplayName="bordercolor" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>#FFEBCD</Default></Field>
A attach a full copy of a working lint definition:
<?xml version="1.0" encoding="utf-8"?><List xmlns:ows="Microsoft SharePoint" Title="PresentationLI" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/PresentationLI" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/"><MetaData><Fields><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B81}" Name="topstartx" DisplayName="topstartx" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B82}" Name="topstarty" DisplayName="topstarty" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B83}" Name="topendx" DisplayName="topendx" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE" /><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B84}" Name="topendy" DisplayName="topendy" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B85}" Name="middlestartx" DisplayName="middlestartx" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B86}" Name="middlestarty" DisplayName="middlestarty" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B87}" Name="middleendx" DisplayName="middleendx" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B88}" Name="middleendy" DisplayName="middleendy" Type="Integer" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B89}" Name="offsetx" DisplayName="offsetx" Type="Integer" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B90}" Name="offsety" DisplayName="offsety" Type="Integer" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B91}" Name="name" DisplayName="name" Type="Text" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B92}" Name="description" DisplayName="description" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B93}" Name="version" DisplayName="version" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B94}" Name="releasedate" DisplayName="releasedate" Type ="DateTime" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B95}" Name="audience" DisplayName="audience" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B96}" Name="features" DisplayName="features" Type="Note" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B97}" Name="overlayimagetop" DisplayName="overlayimagetop" Type="URL" Required="TRUE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B98}" Name="overlayimagebottom" DisplayName="overlayimagebottom" Type="URL" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B99}" Name="alphatop" DisplayName="alphatop" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>1.0</Default></Field><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B00}" Name="alphabottom" DisplayName="alphabottom" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>1.0</Default></Field><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B01}" Name="overlayimagebottomenabled" DisplayName="overlayimagebottomenabled" Type="Boolean" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B02}" Name="overlaycolorbottom" DisplayName="overlaycolorbottom" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"/><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B03}" Name="bordercolor" DisplayName="bordercolor" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>#FFEBCD</Default></Field><Field ID="{24B3F6C1-B75B-4821-A466-C1E979B87B04}" Name="borderwidth" DisplayName="borderwidth" Type="Text" Required="FALSE" ShowInEditForm="TRUE" ShowInDisplayForm="TRUE" ShowInNewForm="TRUE"><Default>5px</Default></Field></Fields><Views><View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE"><Toolbar Type="Standard" /><XslLink Default="TRUE">main.xsl</XslLink><RowLimit Paged="TRUE">30</RowLimit><ViewFields><FieldRef Name="LinkTitleNoMenu"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" /><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" /></ParameterBindings></View><View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx"><Toolbar Type="Standard" /><XslLink Default="TRUE">main.xsl</XslLink><RowLimit Paged="TRUE">30</RowLimit><ViewFields><FieldRef Name="Attachments"></FieldRef><FieldRef Name="LinkTitle"></FieldRef><FieldRef Name="topstartx"> </FieldRef><FieldRef Name="topstarty"></FieldRef><FieldRef Name="topendx"></FieldRef><FieldRef Name="topendy"></FieldRef><FieldRef Name="middlestartx"></FieldRef><FieldRef Name="middlestarty"></FieldRef><FieldRef Name="middleendx"></FieldRef><FieldRef Name="middleendy"></FieldRef><FieldRef Name="offsetx"></FieldRef><FieldRef Name="offsety"></FieldRef><FieldRef Name="name"></FieldRef><FieldRef Name="description"></FieldRef><FieldRef Name="version"></FieldRef><FieldRef Name="releasedate"></FieldRef><FieldRef Name="audience"></FieldRef><FieldRef Name="features"></FieldRef><FieldRef Name="overlayimagetop"></FieldRef><FieldRef Name="overlayimagebottom"></FieldRef><FieldRef Name="overlayimagebottomenabled"></FieldRef><FieldRef Name="overlaycolorbottom"></FieldRef><FieldRef Name="alphatop"></FieldRef><FieldRef Name="alphabottom"></FieldRef><FieldRef Name="bordercolor"></FieldRef><FieldRef Name="borderwidth"></FieldRef></ViewFields><Query><OrderBy><FieldRef Name="ID"></FieldRef></OrderBy></Query><ParameterBindings><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /></ParameterBindings></View></Views><Forms><Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /><Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /><Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" /></Forms></MetaData></List>
No comments:
Post a Comment