What you create isn't what you see

Man, what a day. First off somewhere along the line I deleted my IE7 post accidently and now there's a pretty sufficient fire blazing at Toronto airport from an Air France plane that skidded off the runway. Yeah, a blog posting doesn't seem that significant after an event like that. Anyways, I don't think my IE7 post got cached because of the short time it was online but oh well, nothing too important. Note to self: blog offline first, then post. Yeah, I do things the old-fashioned way right online. I should know better.

Anyways, todays fun ways to torment your SharePoint experience is about what you create using custom definition files and what you get on the other end isn't always the same. Actually it's better.

Let's say you want to create a custom list so you make your copy of CUSTLIST (as we all do) and go and add some fields like so:

<Field Name="ProjectStatus" DisplayName="Project Status" ReadOnly="TRUE" Type="Text"/>
<Field Name="DraftDate" DisplayName="Draft Date" Type="DateTime" Format="DateOnly" ReadOnly="TRUE"/>

Great. Now you deploy it and go into your Create page to find your new list all ready to be generated. Off you go and you have your new list with it's custom fields intact. Brilliant. But did you know that SharePoint is going to add a whack of new and cool fields that you can then use in displays? Here's the new stuff that gets added to your original definition after creation:

<Field ColName="tp_ID" ReadOnly="TRUE" Type="Counter" Name="ID" PrimaryKey="TRUE" DisplayName="ID" FromBaseType="TRUE"/>
<Field Type="Text" Name="Title" DisplayName="Title" Required="TRUE" FromBaseType="TRUE" Hidden="TRUE" ColName="nvarchar1"/>
<Field ColName="tp_Modified" ReadOnly="TRUE" Type="DateTime" Name="Modified" DisplayName="Modified" StorageTZ="TRUE" FromBaseType="TRUE"/>
<Field ColName="tp_Created" ReadOnly="TRUE" Type="DateTime" Name="Created" DisplayName="Created" StorageTZ="TRUE" FromBaseType="TRUE"/>
<Field ColName="tp_Author" ReadOnly="TRUE" Type="User" List="UserInfo" Name="Author" DisplayName="Created By" FromBaseType="TRUE"/>
<Field ColName="tp_Editor" ReadOnly="TRUE" Type="User" List="UserInfo" Name="Editor" DisplayName="Modified By" FromBaseType="TRUE"/>
<Field ColName="tp_Version" Hidden="TRUE" ReadOnly="TRUE" Type="Integer" SetAs="owshiddenversion" Name="owshiddenversion" DisplayName="owshiddenversion" FromBaseType="TRUE"/>
<Field ColName="tp_HasAttachment" Type="Attachments" Name="Attachments" DisplayName="Attachments" FromBaseType="TRUE"/>
<Field ColName="tp_ModerationStatus" ReadOnly="TRUE" Type="ModStat" Name="_ModerationStatus" DisplayName="Approval Status" Hidden="TRUE" CanToggleHidden="TRUE" Required="FALSE" FromBaseType="TRUE">
   <CHOICES>
      <CHOICE>0;#Approved</CHOICE>
      <CHOICE>1;#Rejected</CHOICE>
      <CHOICE>2;#Pending</CHOICE>
   </CHOICES>
   
<Default>0</Default>
</Field>
<Field ReadOnly="TRUE" Type="Note" Name="_ModerationComments" DisplayName="Approver Comments" Hidden="TRUE" CanToggleHidden="TRUE" Sortable="FALSE" FromBaseType="TRUE" ColName="ntext1"/>
<Field ReadOnly="TRUE" Type="Computed" Name="Edit" Sortable="FALSE" Filterable="FALSE" DisplayName="Edit" AuthoringInfo="(link to edit item)" FromBaseType="TRUE">
</Field>
<Field ReadOnly="TRUE" Type="Computed" Name="LinkTitleNoMenu" DisplayName="Title" Dir="" DisplayNameSrcField="Title" AuthoringInfo="(linked to item)" FromBaseType="TRUE">
   <FieldRefs>
      
<FieldRef Name="Title"/>
   
</FieldRefs>
</Field>
<Field ReadOnly="TRUE" Type="Computed" Name="LinkTitle" DisplayName="Title" DisplayNameSrcField="Title" ClassInfo="Menu" AuthoringInfo="(linked to item with edit menu)" FromBaseType="TRUE">
   <FieldRefs>
      <FieldRef Name="Title"/>
      <FieldRef Name="ID"/>
      <FieldRef Name="LinkTitleNoMenu"/>
   </FieldRefs>
</Field>
<Field ReadOnly="TRUE" Type="Computed" Name="SelectTitle" Hidden="TRUE" CanToggleHidden="TRUE" DisplayName="Select" Dir="" AuthoringInfo="(web part connection)" HeaderImage="blank.gif" Sortable="FALSE" FromBaseType="TRUE">
   <FieldRefs>
      
<FieldRef Name="ID"/>
   
</FieldRefs>
</Field>
<Field Name="InstanceID" DisplayName="InstanceID" ColName="tp_InstanceID" ReadOnly="TRUE" Hidden="TRUE" Type="Integer" Min="0" Max="99991231" Filterable="TRUE" Sortable="TRUE" FromBaseType="TRUE"/>
<Field ColName="tp_ItemOrder" Name="Order" DisplayName="Order" Type="Number" Hidden="TRUE" FromBaseType="TRUE"/>
<Field ColName="tp_GUID" ReadOnly="TRUE" Hidden="TRUE" Type="Guid" Name="GUID" DisplayName="GUID" FromBaseType="TRUE"/>

Nice. Lots of great new columsn here that you can do things with in views, grouping, filtering, etc. The best part is that you can define this before these fields are created. Go ahead and put the ID field in for sorting a view or add the Order field to a view so you can see how SharePoint is sorting your list. Most of them are pretty self-explanatory like Created and Modified are DateTime fields when the item is created and updated. Author and Editor tell you who it was by. Edit is a cool one because it displays an Edit icon that links to your EditForm that's attached to the list. LinkTitle is the typical SharePoint menu you see that will allow you to check files out, edit in the appropriate client tool (Word, Excel, Powerpoint, etc.)

Anyways, something simple but keep it in mind when you're designing solutions as you can leverage these items. Have fun with it and as always use it for good, not evil.

1 Comment

Comments have been disabled for this content.