Thursday 14 October 2010

The Mysterious SourceID Attribute

I see a lot field definitions around that unnecessarily include a SourceID attribute:

<Field
SourceID="http://schemas.microsoft.com/sharepoint/v3"

More often than not, the value of this attribute is set as above. Microsoft's own documentation samples tend to include this attribute.

So what does it do? Not a lot as far as I can tell; I don't include it with my own field definitions because inspecting the field after deployment with SharePoint Manager proves SharePoint sets it automatically with the GUID of the list that created the field. The Field Element documentation also indicates it is optional.

If you're intent on using it, the documentation describes this attribute as "containing the namespace that defines the field, such as http://schemas.microsoft.com/sharepoint/v3" so rather than use the default namespace it may be advisable to use your own (I haven't tried this myself).

If you found this post helpful, please support my advertisers.

2 comments:

  1. The search crawler is using the SourceID to have a pointer to the original field. So when the crawler is creating "multiple" search properties from your one unique field it can "glue" all the additional crawl fields together.

    ReplyDelete
  2. Let me debunk "unnecessarily" here. :)

    You really should include this SourceID when you plan to:

    a) Use the field value as a Quickpart in a Word document in a document library
    b.1) You want to use these Word document in other libaries containing this same field (I should say 'Site Column).
    b.2) You want to save your site (including the Word documents) as a template and deploy it again.

    When your field definition lacks the SourceID, it will be generated automatically for each occurence per library, with that library's GUID.

    Word Quickparts use, amongst other properties, the SourceID to identify the field it should be connecting to. Now, when the field has a newly generated SourceID for each instance, the Quickpart cannot connect.

    Solution is to declare the SourceID in the field definition, and it will never change again.

    note: Site Columns that are manually created in the user-interface are automatically provided with the current web-GUID as SourceID. This will remain the same, even when you "copy/paste" the site template. there is no check if the SourceID is a valid 'source'.

    ReplyDelete

Spam comments will be deleted

Note: only a member of this blog may post a comment.