Olav Aukan Getting information off the Internet is like taking a drink from a fire hydrant…

12Oct/10

SharePoint does not always play nice with comments

Some days ago I was tasked with removing the "Add to my colleagues" button from the My Profile page in SharePoint. This is a one-off page located at the root of the My Site site collection named Person.aspx. So I fired up SharePoint Designer (yes I know, SPD is a great evil, but for these kinds of changes it's really the easiest way) and looked at the file. It turns out that the "Add to my colleagues" button is a control in the PlaceHolderMiniConsole placeholder, so I commented it out and saved the page.

<asp:Content ContentPlaceHolderId="PlaceHolderMiniConsole" runat="server">
	<SPSWC:MiniConsole runat="server" id="miniConsole">
	<SPSWC:SPSRepeatedControls id="RptControls" runat="server" HeaderHtml="" BeforeControlHtml="<td class='ms-toolbar' nowrap='true' ID='_spFocusHere'>" AfterControlHtml="</td>" SeparatorHtml="<td class=ms-separator>|</td>">
		<Template_Controls>
			<SPSWC:ReturnToSiteButton runat="server" id="TBBReturnToSite" class="ms-toolbar" ShowImageAndText="false"/>
			<!--<SPSWC:AddToColleaguesButton runat="server" visible="false" id="TBBAddtoColleagues" class="ms-toolbar" ShowImageAndText="false"/>-->
			<SPSWC:AsSeenBy runat="server" id="ddlAsSeenBy" SelectionMode="Single" autopostback=true/>
		</Template_Controls>
	</SPSWC:SPSRepeatedControls>
  </SPSWC:MiniConsole>
</asp:Content>

Much to my surprise nothing happened and the control was still rendered. I tried to revert Person.aspx to it's definition and do the changes again, I tried disabling the cache, I tried iisreset, but nothing worked. In the end I deleted the control instead of commenting it out. That worked...

A colleague of mine had a different problem. His content type was suddenly missing a site column. He was being a good developer and deploying it with XML, just like Microsoft tell you to do. I'm sure we all know about the MANY issues with this approach. So many in fact that I'm almost considering using the object model to add my site columns and content types on my next project, but that's a different subject altogether... We looked at the XML and couldn't see anything wrong with it:

<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D000cba91cafa2b473e85a2e018ed328699"
               Name="InsideBaseArticle"
               Group="Inside Portal"
               Description="Base Content Type for publishing content in the Inside Portal"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{6440A642-CE85-4AF3-BFF7-1900D5095D87}" />   <!-- Tax Note Field -->
      <FieldRef ID="{D5F62894-71DA-49E1-88CE-A8FBBCBFCE2F}" Name="Via" />  <!-- Tax Field -->
      <FieldRef ID="{9DFA6A86-70E7-4470-B3FD-4D68D1FDD1A5}" Name="Summary"  Required="FALSE" />
      <FieldRef ID="{5a14d1ab-1513-48c7-97b3-657a5ba6c742}" Name="AverageRating" />
      <FieldRef ID="{b1996002-9167-45e5-a4df-b2c41c6723c7}" Name="RatingCount" />
    </FieldRefs>
</ContentType>

Turns out it was the comments in the FieldRefs section. Removing them and deploying again resolved the issue.

Moral of the story? SharePoint doesn't always play nice with comments...

Tagged as: 2 Comments