<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Sharepoint Gotchas</title>
        <link>http://geekswithblogs.net/dotnetrodent/category/8438.aspx</link>
        <description>Tips and gotchas that could come up in sharepoint development</description>
        <language>en-US</language>
        <copyright>Adrian Hara</copyright>
        <managingEditor>adrian.hara@iquestint.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>How to check if a sharepoint 2007 workflow is running</title>
            <link>http://geekswithblogs.net/dotnetrodent/archive/2008/08/13/124408.aspx</link>
            <description>&lt;p&gt;Searching for a way to check if a workflow is running on a list item (useful, for example, in an item event handler), I found some code like this:&lt;/p&gt;  &lt;p&gt;        public static bool IsWorkflowRunning(SPListItem listItem, Guid workflowId)    &lt;br /&gt;        {     &lt;br /&gt;            foreach (SPWorkflow workflow in listItem.Workflows)     &lt;br /&gt;            {     &lt;br /&gt;                if (workflow.ParentAssociation.BaseTemplate.Id == workflowId &amp;amp;&amp;amp;     &lt;br /&gt;                    workflow.InternalState == SPWorkflowState.Running)     &lt;br /&gt;                {     &lt;br /&gt;                    return true;     &lt;br /&gt;                }     &lt;br /&gt;            }     &lt;br /&gt;            return false;     &lt;br /&gt;        }&lt;/p&gt;  &lt;p&gt;What this code does is iterate the workflows list for the item (point to remember: listItem.Workflows contains not only running workflows, but also cancelled or otherwise) and checks the InternalState for the given workflow id. While it might seem ok, as I found out the hard way, it's not. Correct way to check is like so:&lt;/p&gt;  &lt;p&gt;        public static bool IsWorkflowRunning(SPListItem listItem, Guid workflowId)    &lt;br /&gt;        {     &lt;br /&gt;            foreach (SPWorkflow workflow in listItem.Workflows)     &lt;br /&gt;            {     &lt;br /&gt;                if (workflow.ParentAssociation.BaseTemplate.Id == workflowId &amp;amp;&amp;amp;     &lt;br /&gt;                    (workflow.InternalState &amp;amp; SPWorkflowState.Running) == SPWorkflowState.Running)     &lt;br /&gt;                {     &lt;br /&gt;                    return true;     &lt;br /&gt;                }     &lt;br /&gt;            }     &lt;br /&gt;            return false;     &lt;br /&gt;        }&lt;/p&gt;  &lt;p&gt;The somewhat subtle thing to notice is the check: it denotes that the SPWorkflowState is an enum decorated with the [Flags] attribute, which means that the check has to be changed like above.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124408"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124408" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dotnetrodent/aggbug/124408.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Adrian Hara</dc:creator>
            <guid>http://geekswithblogs.net/dotnetrodent/archive/2008/08/13/124408.aspx</guid>
            <pubDate>Wed, 13 Aug 2008 22:00:21 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dotnetrodent/comments/124408.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dotnetrodent/archive/2008/08/13/124408.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dotnetrodent/comments/commentRss/124408.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dotnetrodent/services/trackbacks/124408.aspx</trackback:ping>
        </item>
        <item>
            <title>Refresh SPWorkflowActivationProperties Item</title>
            <link>http://geekswithblogs.net/dotnetrodent/archive/2008/08/08/124310.aspx</link>
            <description>&lt;p&gt;If you're developing workflows for SharePoint 2007, you are probably familiar with the Item property of the SPWorkflowActivationProperties class. Usually your workflow gets an instance of SPWorkflowActivationProperties when the OnWorkflowActivated activity executes, which is bound to a public field on the workflow class so you can hang on to it for the lifetime of the workflow. Perhaps one of the more useful properties of this class is Item, which returns an instance of SPListItem, representing the list item on which the workflow runs. &lt;/p&gt;
&lt;p&gt;This is all fine, but maybe for more than two step workflows or for a better design/maintainability of the code, it makes sense (and I try to do it) to encapsulate the properties (access to) and whatever manipulating logic of the list item in a business class, representing the business concept you're dealing with (for example, I find that using classes like Contract or Customer to work with the item's metadata is nicer than working with SPListItem). A small problem with this approach is that you can't simply wrap the SPListItem instance in your business class, because it's not [Serializable], which means that you'll get some nasty error when SharePoint tries to dehydrate your workflow. In light of this, what I do is wrap a reference to the SPWorkflowActivationProperties instance and have a private property called ListItem which just calls the Item property, like so:&lt;/p&gt;
&lt;p&gt;        private SPListItem ListItem   &lt;br /&gt;
        {    &lt;br /&gt;
              get { return workflowProperties.Item; }    &lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;This worked very good for me until a few days ago, when I had a workflow that runs over items in a document library and had to replace the actual document file at some point (like replace a .doc with a generated .pdf from it). The replacement worked fine (I won't go into details, google has answers ;)), but &lt;strong&gt;after&lt;/strong&gt; the replacement, if, &lt;strong&gt;during the same call&lt;/strong&gt; (meaning before the workflow gets dehydrated again), I wanted to do something else with the file, or even call Update() on the SPListItem, exceptions got thrown, with messages like "the file has been modified by blah blah". After some investigations I realized that that although I was modifying the SPFile (which i got from SPListItem.File) and calling Update() on it, this didn't do anything (for example, looking at the SPListItem.File.Name, I'd still get "somepath/somename.&lt;strong&gt;doc&lt;/strong&gt;" instead of "somepath/somename.&lt;strong&gt;pdf&lt;/strong&gt;"). Also, the next logical solution, calling Update() or SystemUpdate() on the SPListItem itself would throw, as stated above. However, if, after modifying and/or replacing the file, I wouldn't do anything else and just let the workflow dehydrate, whenever it would get hydrated again, everything would work: this makes sense, since the SPListItem is not serialized and would be created again after rehydration.&lt;/p&gt;
&lt;p&gt;So, the next step would be looking when is the SPListItem of SPWorkflowActivationProperties created and how can we refresh it "on the fly". Reflector shows the following:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/dotnetrodent/WindowsLiveWriter/RefreshSPWorkflowActivationPropertiesIte_99EF/ItemProperty.jpg"&gt;&lt;img height="465" width="771" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/dotnetrodent/WindowsLiveWriter/RefreshSPWorkflowActivationPropertiesIte_99EF/ItemProperty_thumb.jpg" alt="ItemProperty" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;As you can see, the item is actually cached after the first call. This means that when updating the SPFile associated with the item and calling Update() on it, since this doesn't cause the item itself to update (or at least update its SPFile), we have to somehow refresh the whole SPListItem. While the SPWorkflowActivationProperties class doesn't expose some method to do this, it's easy to do with reflection: just set the m_item to null and on the next call to the property, it will be recreated. One thing to note here is that, as seen in the picture above, there are two cases where the item can be refreshed: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;for non super user workflows, a call is made to the list directly for the item&lt;/li&gt;
    &lt;li&gt;for super user workflow, a call is made to SPWorkflow.ParentItem&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Looking at the SPWorkflow.ParentItem with reflector, it turns out that the value backing the property is also cached:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/dotnetrodent/WindowsLiveWriter/RefreshSPWorkflowActivationPropertiesIte_99EF/ParentItemProperty_1.jpg"&gt;&lt;img height="307" width="777" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/dotnetrodent/WindowsLiveWriter/RefreshSPWorkflowActivationPropertiesIte_99EF/ParentItemProperty_thumb_1.jpg" alt="ParentItemProperty" style="border: 0px none ;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;So, in order to be fully covered for all situations, the method to invalidate the list item and make sure it's refreshed should look like so:&lt;/p&gt;
&lt;p&gt;        private void InvalidateWorkflowPropertiesItem()   &lt;br /&gt;
        {    &lt;br /&gt;
            FieldInfo parentItemField = workflowProperties.Workflow.GetType().GetField("m_createdParentItem", BindingFlags.NonPublic | BindingFlags.Instance);    &lt;br /&gt;
            parentItemField.SetValue(workflowProperties.Workflow, null); &lt;/p&gt;
&lt;p&gt;            FieldInfo itemField = workflowProperties.GetType().GetField("m_item", BindingFlags.NonPublic | BindingFlags.Instance);   &lt;br /&gt;
            itemField.SetValue(workflowProperties, null);    &lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Normally, you should just call this method after doing something that causes the SPFile for an item to change, but I guess there are probably other situations where refreshing of the list item would come in handy.&lt;/p&gt;
&lt;p&gt;ps: another approach to the basic problem that the SPListItem isn't serializable would be to keep it's unique id and retrieve it like that every time you need it, but this could mean implementing the caching and getting mechanisms yourself if you want to have some business class wrapper over it (meaning that you can't just GetByUniqueId() it every time you need to change a property, because you'd end up with a different instance every time and would have to be careful about updating it) &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124310"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124310" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dotnetrodent/aggbug/124310.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Adrian Hara</dc:creator>
            <guid>http://geekswithblogs.net/dotnetrodent/archive/2008/08/08/124310.aspx</guid>
            <pubDate>Fri, 08 Aug 2008 16:28:51 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dotnetrodent/comments/124310.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dotnetrodent/archive/2008/08/08/124310.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dotnetrodent/comments/commentRss/124310.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dotnetrodent/services/trackbacks/124310.aspx</trackback:ping>
        </item>
        <item>
            <title>Sharepoint 2007 - List vs. inherited content types gotcha</title>
            <link>http://geekswithblogs.net/dotnetrodent/archive/2008/07/16/123817.aspx</link>
            <description>The following gotcha was a pretty nasty one for me (I'd say about 2 hours of lost time worth). Supposing you have some content types deployed at the site collection level and you want to add them to a document library of a sub-site (web) plus configure them a little bit, like so:&lt;br /&gt;
&lt;br /&gt;
            foreach (string contentTypeName in ToAttachToListContentTypeNames)&lt;br /&gt;
            {&lt;br /&gt;
                // Get site collection content type&lt;br /&gt;
                SPContentType siteContentType = web.AvailableContentTypes[contentTypeName];&lt;br /&gt;
&lt;br /&gt;
                // Add to library and configure&lt;br /&gt;
                SPContentType libraryContentType = library.ContentTypes.Add(siteContentType);&lt;br /&gt;
                libraryContentType.DocumentTemplate = string.Empty;&lt;br /&gt;
                libraryContentType.Update(false);&lt;br /&gt;
&lt;br /&gt;
               // Maybe some more work, like adding some linked fields here?...&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
This turned out to result in some weird behavior: supposing I had 3 content types to add to the document library, the first one of them (which would also be the first one added) always got some of its properties wrong. For example, even though the code sets the DocumentTemplate explicitly to string.Empty, the resulting document library content type (the first one added) would always get the "template.doc" template instead. Weird stuff happened also to some linked fields I was adding, like the first content type would always get one linked field less than the others &lt;img src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/confused_smile.gif" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Now, unfortunately (or fortunately?) I didn't have the time to Reflect over the sharepoint code to see why this happens, but after some trial-and-errors I found that it seems the call to "library.ContentTypes" somehow merges the "web.AvailableContentTypes" with the library's content types. Since this call is done in the foreach loop, it means that, for each subsequent loop step, some settings for the content types added in prior steps are "merged" (read overwritten) with the ones of the site collection content types. What's weird is that:&lt;br /&gt;
1. It only seemed to happen for the first added content type (so the first step in the loop). The other two were fine.&lt;br /&gt;
2. It only "merged" some of its properties, like DocumentTemplate and *some* field links, not all &lt;img src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Anyway, the fix is to take the call to "library.ContentTypes" out of the loop and assign to a variable. Then you can just iterate over that "local" collection and do stuff:&lt;br /&gt;
&lt;br /&gt;
            SPContentTypeCollection availableContentTypes = web.AvailableContentTypes;&lt;br /&gt;
            foreach (string contentTypeName in ToAttachContentTypeNames)&lt;br /&gt;
            {&lt;br /&gt;
                // Get site collection content type&lt;br /&gt;
                SPContentType siteContentType = availableContentTypes[contentTypeName];&lt;br /&gt;
&lt;br /&gt;
                // Add to library and configure&lt;br /&gt;
                SPContentType libraryContentType = library.ContentTypes.Add(siteContentType);&lt;br /&gt;
                libraryContentType.DocumentTemplate = string.Empty;&lt;br /&gt;
                libraryContentType.Update(false);&lt;br /&gt;
            }&lt;br /&gt;
            library.Update();&lt;br /&gt;
&lt;br /&gt;
            // Add some fieldlinks to the library content types&lt;br /&gt;
            SPContentTypeCollection libraryContentTypes = library.ContentTypes;&lt;br /&gt;
            foreach (string contentTypeName in ToExtendWithFieldLinksContentTypes)&lt;br /&gt;
            {&lt;br /&gt;
                SPContentType libraryContentType = libraryContentTypes[contentTypeName];&lt;br /&gt;
&lt;br /&gt;
                SPFieldLink someFieldLink = new SPFieldLink(web.Fields["some field"]);&lt;br /&gt;
                libraryContentType.FieldLinks.Add(someFieldLink );&lt;br /&gt;
&lt;br /&gt;
                // Maybe add some more...&lt;br /&gt;
               &lt;br /&gt;
                libraryContentType.Update(false);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
This seems to work, but granted, is strange enough to do...&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123817"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123817" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dotnetrodent/aggbug/123817.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Adrian Hara</dc:creator>
            <guid>http://geekswithblogs.net/dotnetrodent/archive/2008/07/16/123817.aspx</guid>
            <pubDate>Wed, 16 Jul 2008 22:16:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dotnetrodent/comments/123817.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dotnetrodent/archive/2008/07/16/123817.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/dotnetrodent/comments/commentRss/123817.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dotnetrodent/services/trackbacks/123817.aspx</trackback:ping>
        </item>
        <item>
            <title>Sharepoint custom content type without columns problem</title>
            <link>http://geekswithblogs.net/dotnetrodent/archive/2008/07/13/123766.aspx</link>
            <description>To paraphrase a &lt;a href="http://www.hanselman.com/"&gt;heavyweight blogger&lt;/a&gt;, this is the first post in (probably) a infinite number of posts about &lt;a href="http://geekswithblogs.net/dotnetrodent/category/8438.aspx"&gt;Sharepoint Gotchas&lt;/a&gt;. &lt;img alt="" src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/tounge_smile.gif" /&gt;&lt;br /&gt;
&lt;br /&gt;
Today's gotcha: why doesn't my custom content type have any columns? &lt;br /&gt;
&lt;br /&gt;
It took me quite some time (including a little foaming-at-the-mouth time) to figure this out. Suppose you declare a custom content type in CAML that you'd like to just inherit all its columns from its base content type, without defining any of its own, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ContentType&lt;br /&gt;
      ID="0x010100D4C041607B6A400dB211CC424B2D153BAB"&lt;br /&gt;
      Name="My Content Type"&lt;br /&gt;
      Description="Foobar content type"&lt;br /&gt;
      Version="0" &lt;br /&gt;
      Group="Foobar Group" &amp;gt;&lt;br /&gt;
  &amp;lt;/ContentType&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All is well, it deploys fine, just that when you want to use it it turns out it didn't actually inherit any of its parent type's columns, but rather has an empty Columns list. The problem is pretty subtle, if you ask me, and stems from the fact that you should've declared the content type like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ContentType&lt;br /&gt;
      ID="0x010100D4C041607B6A400dB211CC424B2D153BAB"&lt;br /&gt;
      Name="My Content Type"&lt;br /&gt;
      Description="Foobar content type"&lt;br /&gt;
      Version="0" &lt;br /&gt;
      Group="Foobar Group" &amp;gt;&lt;br /&gt;
    &amp;lt;FieldRefs/&amp;gt;&lt;br /&gt;
  &amp;lt;/ContentType&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you spot the difference yet? It's the &amp;lt;FieldRefs/&amp;gt; element. So even if you don't declare any columns, you still have to include the empty FieldRefs element. What's even nastier is that the schema validates without it :(...&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123766"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123766" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dotnetrodent/aggbug/123766.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Adrian Hara</dc:creator>
            <guid>http://geekswithblogs.net/dotnetrodent/archive/2008/07/13/123766.aspx</guid>
            <pubDate>Sun, 13 Jul 2008 16:59:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dotnetrodent/comments/123766.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dotnetrodent/archive/2008/07/13/123766.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dotnetrodent/comments/commentRss/123766.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dotnetrodent/services/trackbacks/123766.aspx</trackback:ping>
        </item>
        <item>
            <title>Sharepoint 2007 ID and GUID conventions</title>
            <link>http://geekswithblogs.net/dotnetrodent/archive/2008/07/06/123611.aspx</link>
            <description>Due to much frustration and lost time, I'll try to summarize in this post the "naming" conventions to be used when defining and/or referencing IDs (some of which are, in fact, GUIDs, and others contain GUIDs) in Sharepoint 2007. &lt;br /&gt;
&lt;br /&gt;
If you're thinking "what the heck?! aren't GUIDs always the same format?!" you're half-right: they should be, but not in sharepoint. So if you're a newbie to sharepoint 2007 (or wss 3.0) like me, the following tips regarding how element id's should be written might save you some time (because if you get them wrong, the error messages from sharepoint are somewhat... cryptic). I've two conventions pinned down so far, but I'm just learning, so if you know any more, please share.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
    &lt;li&gt;Site Column definitions: defined using a &amp;lt;Field&amp;gt; xml element (&lt;a href="javascript:void(0);/*1215353396203*/"&gt;more info on MSDN&lt;/a&gt;), their id's must have the form &lt;span style="font-weight: bold;"&gt;{GUID}&lt;/span&gt;. Note the brackets, &lt;span style="font-weight: bold;"&gt;they are mandatory&lt;/span&gt;, else you'll get an error (in the logs only) along the lines of "unable to locate the xml-field definition for FieldName with FieldId 'your_guid'". Another thing to remember is that the brackets are also mandatory wherever this site column is referenced (like in a content type). Thanks to &lt;a href="javascript:void(0);/*1215353706765*/"&gt;Edwin Vriethoff for this tip&lt;/a&gt;.&lt;/li&gt;
    &lt;li&gt;Content Types: as you probably know, the content type id is not actually a GUID, but a concatenation of the base content type id, "00" and a Guid. The catch here is that the Guid (third part in the concatenated string) must be written &lt;span style="font-weight: bold;"&gt;without dashes&lt;/span&gt;. So, instead of "0x010012B0E62B-D58E-4d6e-94A1-E36B3F7807E1", write "0x010012B0E62BD58E4d6e94A1E36B3F7807E1". Easy one to get wrong, especially if you use vs.net's guid generator in registry format. The error message from sharepoint in this case is very clear and helpful: "value does not fall within expected range" :)&lt;/li&gt;
&lt;/ol&gt;
It's actually too bad that 1) these gotchas exist and 2) the problems are not easy to figure out using the error messages from sharepoint. Hopefully, this post will help somewhat.&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123611"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123611" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/dotnetrodent/aggbug/123611.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Adrian Hara</dc:creator>
            <guid>http://geekswithblogs.net/dotnetrodent/archive/2008/07/06/123611.aspx</guid>
            <pubDate>Sun, 06 Jul 2008 22:18:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/dotnetrodent/comments/123611.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/dotnetrodent/archive/2008/07/06/123611.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/dotnetrodent/comments/commentRss/123611.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/dotnetrodent/services/trackbacks/123611.aspx</trackback:ping>
        </item>
    </channel>
</rss>