<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mexican Rat Dog &#187; SharePoint</title>
	<atom:link href="http://www.mexicanratdog.com/category/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mexicanratdog.com</link>
	<description>Yet another blog about software, life, and whatever else I write about.</description>
	<lastBuildDate>Mon, 30 Jan 2012 03:32:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Indentity Crisis</title>
		<link>http://www.mexicanratdog.com/2010/07/06/indentity-crisis/</link>
		<comments>http://www.mexicanratdog.com/2010/07/06/indentity-crisis/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:24:22 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://mexicanratdog.com/?p=148</guid>
		<description><![CDATA[For the longest time, I have been trying to get away from M$ products and my dependence upon them.  My blog, however, continues to generate a majority of its hits from just a few very specific articles on Microsoft SharePoint.  It seems that I will have to do a lot more blogging to steer myself <a href="http://www.mexicanratdog.com/2010/07/06/indentity-crisis/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the longest time, I have been trying to get away from M$ products and my dependence upon them.  My blog, however, continues to generate a majority of its hits from just a few very specific articles on Microsoft SharePoint.  It seems that I will have to do a lot more blogging to steer myself away from this unwanted association!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2010/07/06/indentity-crisis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SP Gotchas] Error When Programmatically Starting Workflow</title>
		<link>http://www.mexicanratdog.com/2008/03/14/sp-gotchas-error-when-programmatically-starting-workflow/</link>
		<comments>http://www.mexicanratdog.com/2008/03/14/sp-gotchas-error-when-programmatically-starting-workflow/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 13:42:35 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/?p=59</guid>
		<description><![CDATA[I&#8217;ve recently had a need to model a looping workflow with a SharePoint Designer workflow.  Designer doesn&#8217;t have a &#8216;Start Workflow&#8217; action available by default, so I installed the Useful SharePoint Designer Workflow Activities on Codeplex. My workflow would be designed like this Collect Data From Users with Task Form Set Workflow Variable to Step <a href="http://www.mexicanratdog.com/2008/03/14/sp-gotchas-error-when-programmatically-starting-workflow/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently had a need to model a looping workflow with a SharePoint Designer workflow.  Designer doesn&#8217;t have a &#8216;Start Workflow&#8217; action available by default, so I installed the <a href="http://www.codeplex.com/SPDActivities">Useful SharePoint Designer Workflow Activities </a>on Codeplex.</p>
<p>My workflow would be designed like this</p>
<ol>
<li>
<div>Collect Data From Users with Task Form</div>
</li>
<li>
<div>Set Workflow Variable to Step 1 Task ID</div>
</li>
<li>
<div>Check for repeat condition on Above Task</div>
<ol>
<li>
<div>Start a new instance of this workflow</div>
</li>
</ol>
</li>
<li>(Workflow Done)</li>
</ol>
<p>Looks great, but when running this workflow, I kept getting the following error:</p>
<p><font size="2">Exception from HRESULT: 0x8102009B</font></p>
<p>at Microsoft.SharePoint.Library.SPRequest.AddWorkflowToListItem(String bstrUrl, String bstrListName, Int32 lItemID, Int32 lItemLevel, Int32 lItemVersion, Guid workflowPackageId, Guid&amp; pWorkflowInstanceId, Guid workflowTaskListId, String bstrStatusFieldInternalName, Int32 lAuthorId)</p>
<p>I searched around and found out that you <em>cannot </em>start an instance of a workflow on an item when the same workflow is already running on that item.  <a href="http://blogs.tamtam.nl/lucy/CommentView,guid,a968f4f1-d433-476d-9764-319d3906290d.aspx">Lucy&#8217;s blog </a>had a code sample which checked the target item for the duplicate WF and removed the WF if it was found.  I wanted to keep the data from the first workflow, and this would remove it.  Not exactly what I wanted.</p>
<p>Here&#8217;s a simpler approach I took:</p>
<p>Modify the original workflow (Workflow A)&#8230;</p>
<ol>
<li>
<div>Collect Data From Users with Task Form</div>
</li>
<li>
<div>Set Workflow Variable to Step 1 Task ID</div>
<ol>
<li>
<div>Check for repeat condition on Above Task</div>
</li>
<li>
<div>Start a new instance of the LookBack workflow</div>
</li>
<li>
<div>Stop this workflow and log the message &#8216;Completed &#8211; Looping&#8217;</div>
</li>
</ol>
</li>
<li>
<div>(Workflow Done)</div>
</li>
</ol>
<p>Create a second workflow called &#8216;LoopBack&#8217;:</p>
<ol>
<li>
<div>Pause for 1 minute</div>
</li>
<li>
<div>Start a new instance of Workflow A</div>
</li>
<li>
<div>(Workflow Done)</div>
</li>
</ol>
<p>I can start an instance of LoopBack at the same time as Workflow A.  Then, LoopBack waits while Workflow A completes.  After that, it starts Workflow A over again.  The pause is there since Workflow A takes some time to fully complete.</p>
<p><em>Note, if you&#8217;re not running SP1, the Pause for 1 minute step will take 30 minutes to complete.  Installing SP1 will fix this issue.</em></p>
<p>This is a really simple way to model a looping workflow without going into Visual Studio.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/03/14/sp-gotchas-error-when-programmatically-starting-workflow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint Content Deployment Job Stuck at &#8216;Preparing&#8217;</title>
		<link>http://www.mexicanratdog.com/2008/03/10/sharepoint-content-deployment-job-stuck-at-preparing/</link>
		<comments>http://www.mexicanratdog.com/2008/03/10/sharepoint-content-deployment-job-stuck-at-preparing/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 16:43:57 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/?p=56</guid>
		<description><![CDATA[Not only did DST rob me of an hour of sleep this weekend, it&#8217;s also slowing down my content deployment jobs!  Thanks a lot, Benjamin Franklin! This KB article seems to explain the problem as beeing that the OWSTIMER has its own clock which is separate from the system clock.  I scheduled a job for <a href="http://www.mexicanratdog.com/2008/03/10/sharepoint-content-deployment-job-stuck-at-preparing/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Not only did <a href="http://en.wikipedia.org/wiki/Daylight_saving_time">DST</a> rob me of an hour of sleep this weekend, it&#8217;s also slowing down my content deployment jobs!  Thanks a lot, <a href="http://en.wikipedia.org/wiki/Daylight_savings_time">Benjamin Franklin</a>!</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1347425&amp;SiteID=1">This KB article</a> seems to explain the problem as beeing that the OWSTIMER has its own clock which is separate from the system clock.  I scheduled a job for 11:17am this morning and it showed a status of &#8216;preparing&#8217; until 12:17pm, at which time it ran smoothly.</p>
<p>A couple of solutions: set your jobs to run as if you were still in non-DST.  Right now, that would mean that I would schedule a job for one hour from now if I wanted it to run immediately.  Second solution: change your server time zone to a non-DST time zone and disable automatic time updates.</p>
<p><em>Update 2008-03-11:<br />
</em>Install SP1 to alleviate this problem!  I assumed the server I was working on had SP1, but I was wrong.  Running the update fixed the problem immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/03/10/sharepoint-content-deployment-job-stuck-at-preparing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SP Gotchas] Core.css Keeps Overriding My Styles!</title>
		<link>http://www.mexicanratdog.com/2008/02/27/sp-gotchas-corecss-keeps-overriding-my-styles/</link>
		<comments>http://www.mexicanratdog.com/2008/02/27/sp-gotchas-corecss-keeps-overriding-my-styles/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 20:52:16 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/?p=55</guid>
		<description><![CDATA[If you use the CssRegistration and CssLink controls on a SharePoint page, core.css is always added to the HTML page last.  This means that any styles in core.css will override the styles you&#8217;ve defined in your custom stylesheets.  Does this make sense?! No.  But, like many other things in SharePoint, that&#8217;s the way it is. <a href="http://www.mexicanratdog.com/2008/02/27/sp-gotchas-corecss-keeps-overriding-my-styles/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you use the CssRegistration and CssLink controls on a SharePoint page, core.css is always added to the HTML page last.  This means that any styles in core.css will override the styles you&#8217;ve defined in your custom stylesheets.  Does this make sense?! No.  But, like many other things in SharePoint, that&#8217;s the way it is.</p>
<p>A quick way to fix this is to just use a plain &lt;link &#8230;&gt; tag to include your stylesheets.  Since those aren&#8217;t processed server-side like links in the controls mentioned above, they will be loaded in the order you define in the HTML.</p>
<p>Heather Solomon has <a href="http://heathersolomon.com/blog/archive/2006/10/27/sp07cssoptions.aspx">a blog post </a>about this issue as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/27/sp-gotchas-corecss-keeps-overriding-my-styles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[SP Gotchas] SharePoint and the Name.dll</title>
		<link>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-sharepoint-and-the-namedll/</link>
		<comments>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-sharepoint-and-the-namedll/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 14:33:12 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/?p=53</guid>
		<description><![CDATA[SharePoint has a nifty little feature which allows logged-in users to tell which other users are logged in (or away, or idle, etc.)  While this is a handy thing to have in an intranet setting, having your users prompted with the Name.dll download on a public web site isn&#8217;t desirable.  Here&#8217;s how to get rid <a href="http://www.mexicanratdog.com/2008/02/21/sp-gotchas-sharepoint-and-the-namedll/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SharePoint has a nifty little feature which allows logged-in users to tell which other users are logged in (or away, or idle, etc.)  While this is a handy thing to have in an intranet setting, having your users prompted with the Name.dll download on a <em>public </em>web site isn&#8217;t desirable.  Here&#8217;s how to get rid of that pesky download prompt:</p>
<p><a href="http://support.microsoft.com/kb/931509">http://support.microsoft.com/kb/931509</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-sharepoint-and-the-namedll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SP Gotchas] SPD Says a File is Checked Out When it Really Isn&#8217;t</title>
		<link>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-spd-says-a-file-is-checked-out-when-it-really-isnt/</link>
		<comments>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-spd-says-a-file-is-checked-out-when-it-really-isnt/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 14:30:33 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/2008/02/21/sp-gotchas-spd-says-a-file-is-checked-out-when-it-really-isnt/</guid>
		<description><![CDATA[Ever have SharePoint Designer tell you that something is checked out, but you know that it really isn&#8217;t? Here&#8217;s a link forwarded to me by a coworker:  http://robgarrett.com/cs/blogs/software/archive/2007/12/14/sharepoint-designer-and-sharepoint-out-of-sync.aspx]]></description>
			<content:encoded><![CDATA[<p>Ever have SharePoint Designer tell you that something is checked out, but you know that it really isn&#8217;t?  Here&#8217;s a link forwarded to me by a coworker:</p>
<p><a href="http://robgarrett.com/cs/blogs/software/archive/2007/12/14/sharepoint-designer-and-sharepoint-out-of-sync.aspx"> http://robgarrett.com/cs/blogs/software/archive/2007/12/14/sharepoint-designer-and-sharepoint-out-of-sync.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/21/sp-gotchas-spd-says-a-file-is-checked-out-when-it-really-isnt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing SharePoint Content Reports</title>
		<link>http://www.mexicanratdog.com/2008/02/19/customizing-sharepoint-content-reports/</link>
		<comments>http://www.mexicanratdog.com/2008/02/19/customizing-sharepoint-content-reports/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 22:08:16 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/2008/02/19/customizing-sharepoint-content-reports/</guid>
		<description><![CDATA[Here&#8217;s a useful article with instructions on how to add new reports to the Site Actions / View Reports menu: http://blogs.msdn.com/ecm/archive/2006/11/15/report-rapport.aspx]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a useful article with instructions on how to add new reports to the Site Actions / View Reports menu:</p>
<p><a href="http://blogs.msdn.com/ecm/archive/2006/11/15/report-rapport.aspx">http://blogs.msdn.com/ecm/archive/2006/11/15/report-rapport.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/19/customizing-sharepoint-content-reports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SharePoint Content and Structure Reports not Showing</title>
		<link>http://www.mexicanratdog.com/2008/02/19/sharepoint-content-and-structure-reports-not-showing/</link>
		<comments>http://www.mexicanratdog.com/2008/02/19/sharepoint-content-and-structure-reports-not-showing/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 22:00:24 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/?p=45</guid>
		<description><![CDATA[While working on a client’s MOSS 2007 public web site, I noticed that none of the reports in the Site Content and Structure page were not working. (There were duplicates as well, which I fixed by simply deleting the duplicate items from the Content and Structure Reports list at the root level.) I would click <a href="http://www.mexicanratdog.com/2008/02/19/sharepoint-content-and-structure-reports-not-showing/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri">While working on a client’s MOSS 2007 public web site, I noticed that none of the reports in the Site Content and Structure page were not working.  (There were duplicates as well, which I fixed by simply deleting the duplicate items from the Content and Structure Reports list at the root level.) I would click the item in the View drop down list, and the page would simply refresh.<span>  </span>I checked the error log and found the following error:</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri"><code>SMObjectList.SmtReportsList: Reports List was not provisioned</code></font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri">Searching the web only revealed that other people were having the same problem.<span>  </span>Microsoft wrote a </font><a href="http://support.microsoft.com/kb/941861"><font face="Calibri">KB article</font></a><font face="Calibri"> describing at least one symptom I was experiencing: duplicate report entries in the Site Actions menu.<span>  </span>The article did <i>not </i>explain that the hot fix would also remedy the problem of <i>no </i>results showing up.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri">I emailed Microsoft customer support a few times, got the KB download, but didn’t feel very comfortable installing the hot fix on a production server just a few days before go-live.<span>  </span>Also, the verbiage of the installation instructions seemed to imply that I had to export and re-import the site.<span>  </span>Not something I wanted to do.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri">I then did some work to track down the error listed above by using .Net Reflector.<span>  </span>The error was coming from a property called ‘<code>SiteCollectionReportsListId</code>&#8216; on the <code>Microsoft.SharePoint.Publishing.Internal.WebControls.SMObjectList.SmtReportsList </code>class.<span>  </span>Of course, like all nifty properties in SharePoint, it was private.<span>  </span>I was able to figure out where the property was getting its information, which was simply from the AllProperties hashtable in the SPWeb at the root of the site.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri">Writing a quick console app enabled me to find out that the problem site <i>had</i> this property set, but it was set to a GUID which didn’t point to a list on the current site.<span>  </span>This GUID wasn’t changed when the site was imported using STSADM!<span>  </span>I then wrote some more code in my handy little console app and tweaked the property to the <i>valid </i>GUID.<span>  </span>Voila!<span>  </span>Reports started working again!</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Calibri"><a href="http://apqeba.bay.livefilestore.com/y1p6B4HMHr69_VvPZFS74A6sWRp8k-CBvz6Uf3CZJgIROzUw85LSvIff1IScfXk2oY3-ij2YgTvPosrJZiNrWdPYg/SiteCollectionReportsList.zip?download">Source Code</a>  <a href="http://apqeba.bay.livefilestore.com/y1p6B4HMHr69_UqPHKNm5N1Sv4nEdHm48ErmZPCXJUptqz4aCE-DXOvM8E_yGUMotfB-gV41Q3u1kGiWv6z6AG66Q/sitecollectionreportslist.exe">Executable</a></font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/19/sharepoint-content-and-structure-reports-not-showing/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>VSeWSS and WSPBuilder new releases</title>
		<link>http://www.mexicanratdog.com/2008/02/12/vsewss-and-wspbuilder-new-releases/</link>
		<comments>http://www.mexicanratdog.com/2008/02/12/vsewss-and-wspbuilder-new-releases/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 15:37:43 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[VisualStudio]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/2008/02/12/vsewss-and-wspbuilder-new-releases/</guid>
		<description><![CDATA[New versions of Visual Studio Extensions for Windows SharePoint Services and WSPBuilder were released within the last week.  I&#8217;ve used WSPBuilder on many client projects.  VSeWSS has been lacking in features and stability, but it seems like many of the kinks have been worked out in this final version.  The most interesting new feature of VSeWSS is <a href="http://www.mexicanratdog.com/2008/02/12/vsewss-and-wspbuilder-new-releases/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="ForumPostContentText">New versions of <a href="http://blogs.msdn.com/sharepoint/archive/2008/02/11/announcing-the-final-release-of-vsewss-1-1-and-the-upcoming-version-1-2.aspx">Visual Studio Extensions for Windows SharePoint Services</a> and <a href="http://www.codeplex.com/WSPBuilder">WSPBuilder</a> were released within the last week.  I&#8217;ve used WSPBuilder on many client projects.  VSeWSS has been lacking in features and stability, but it seems like many of the kinks have been worked out in this final version.  The most interesting new feature of VSeWSS is the WSP View, which allows you to include or project file from being in the produced WSP.I&#8217;m not sure which tool is better at this point, as I haven&#8217;t tested out VSeWSS yet.</p>
<p><em>Update: 2/28/2008<br />
</em>While I was initially excited about the new VSeWSS, I&#8217;m still a little disappointed.  You can&#8217;t install it on a Vista or XP Machine.  I also like to build my WSP without deploying it or updating the current server (I can&#8217;t update or deploy if I&#8217;m on Vista); WSPBuilder lets me do that.</p>
<p>WSPBuilder also includes some neat things that VSeWW doesn&#8217;t have: a template for a solution with workflow, a template for a workflow feature, a menu item in VS to creates a <a href="http://www.codeplex.com/sharepointinstaller">SharePoint Solution Installer</a> package, the ability to build WSPs via command line, not to mention the configurability offered through the config file (and the open source).</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2008/02/12/vsewss-and-wspbuilder-new-releases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Lookup Site Columns &amp; Target Lists Through a Feature</title>
		<link>http://www.mexicanratdog.com/2007/10/01/create-lookup-site-columns-target-lists-through-a-feature/</link>
		<comments>http://www.mexicanratdog.com/2007/10/01/create-lookup-site-columns-target-lists-through-a-feature/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 19:06:34 +0000</pubDate>
		<dc:creator>mexicanratdog</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>

		<guid isPermaLink="false">http://mexicanratdog.wordpress.com/2007/10/01/create-lookup-site-columns-target-lists-through-a-feature/</guid>
		<description><![CDATA[Here&#8217;s another provisioning gotcha. I had some problems provisioning a site column which pointed to a list I was also provisioning through a feature. Below are some code examples of how I implemented a quick solution. Say you want to create a new list instance in your feature&#8230; &#60;Elements ...&#62; &#60;ListInstance Id="{A6E8895F-6C4D-4834-9769-CBA700B2356A}" FeatureId="{00bfea71-de22-43b2-a848-c05709900100}" TemplateType="100" Title="Campus <a href="http://www.mexicanratdog.com/2007/10/01/create-lookup-site-columns-target-lists-through-a-feature/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another provisioning gotcha.  I had some problems provisioning a site column which pointed to a list I was also provisioning through a feature.  Below are some code examples of how I implemented a quick solution.</p>
<p><span id="more-36"></span>Say you want to create a new list instance in your feature&#8230;</p>
<pre>&lt;Elements ...&gt;
 &lt;ListInstance Id="{A6E8895F-6C4D-4834-9769-CBA700B2356A}"
 FeatureId="{00bfea71-de22-43b2-a848-c05709900100}"
 TemplateType="100"
 Title="Campus Locations"
 Description="Campus Locations List"
 Url="CampusLocations"
 OnQuickLaunch="false" /&gt;
 &lt;/Elements&gt;</pre>
<p>Now you want to create a site column which will point to the above list in the <em>same </em>feature:</p>
<pre>&lt;Field ID="{E9635D9A-3D47-45b3-B718-CFA54CF0FE50}"
 SourceID="{8c066b26-5a3e-4e1b-85ec-7e584cf178d7}"
 Name="Campus"
 DisplayName="Campus"
 StaticName="Campus"
 Description="The campus or campuses to which this item relates."
 Group="Custom Site Columns"
 Type="LookupMulti"
 List="{A6E8895F-6C4D-4834-9769-CBA700B2356A}"
 ShowField="Title"
 Required="FALSE"
 Mult="TRUE"/&gt;</pre>
<p>You would assume that putting the GUID of the list in the <em>List </em>attribute of the Field element would hook the field  to the list, right?  <em>Wrong</em>.  SharePoint re-creates the GUID of the lists you provision through &lt;ListInstance &#8230;&gt;, so any reference to that hard-coded GUID will fail.  Hmm&#8230;</p>
<p>We <em>can </em>repair the reference to the list through a feature receiver once the column and list have been provisioned.  It take a little prying, but it&#8217;s possible.  I found a <a href="http://www.codeplex.com/SP2007LookupFields">reference </a>on how to do this on <a href="http://www.codeplex.com">CodePlex</a>, but it included a dependency on the feature manifest file, and I didn&#8217;t like that.  The code below uses the XML in the database and recreates a site column pointing to the correct list, based on a string reference you pass in through the &#8216;List&#8217; attribute of the &lt;Field &#8230;&gt; element:</p>
<p><code>public class FeatureReceiver : SPFeatureReceiver<br />
{<br />
public override void FeatureActivated(SPFeatureReceiverProperties properties)<br />
{<br />
RepairLookupColumnReferences(properties);<br />
}</code><code>public override void FeatureDeactivating(SPFeatureReceiverProperties properties)<br />
{<br />
CleanupLookupColumns(properties);<br />
}</code></p>
<pre>public override void FeatureInstalled(SPFeatureReceiverProperties properties)
 {
 }</pre>
<pre>public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
 {
 }</pre>
<pre>private void RepairLookupColumnReferences(SPFeatureReceiverProperties properties)
 {
 // feature is scoped at Site, so the parent is type SPSite rather than SPWeb..
 using (SPSite site = properties.Feature.Parent as SPSite)
 {
 SPWeb currentWeb = null;
 Guid gRootWebId = Guid.Empty;
 if (site != null)
 {
 currentWeb = site.RootWeb;
 gRootWebId = currentWeb.ID;
 }
 else
 {
 currentWeb = properties.Feature.Parent as SPWeb;
 gRootWebId = currentWeb.Site.RootWeb.ID;
 }</pre>
<pre>using (currentWeb)
 {
 // read details from CAML..</pre>
<pre>string sFieldElement = null;
 string sColumnName = null;
 string sListName = null;</pre>
<pre>SPElementDefinitionCollection coll =
 properties.Feature.Definition.GetElementDefinitions(System.Globalization.CultureInfo.CurrentCulture);
 foreach (SPElementDefinition def in coll)
 {
 XmlNode node = def.XmlDefinition;
 XmlNodeReader nReader = new XmlNodeReader(node);
 while (nReader.Read())
 {
 if (nReader.LocalName == "Field")
 {
 //check to see if this is a lookup field
 if (nReader.MoveToAttribute("Type"))
 {
 string type = nReader.Value;
 nReader.MoveToElement();
 if (type.ToLower() != "lookup" &amp;&amp; type.ToLower() != "lookupmulti")
 continue;
 }</pre>
<pre>if (nReader.MoveToAttribute("Name"))
 {
 sColumnName = nReader.Value;
 nReader.MoveToElement();
 }</pre>
<pre>if (nReader.MoveToAttribute("List"))
 {
 sListName = nReader.Value;
 nReader.MoveToElement();
 }</pre>
<pre>sFieldElement = nReader.ReadOuterXml();</pre>
<pre>// now get reference to list, fix up CAML and create column..
 SPList referencedList = currentWeb.Site.RootWeb.Lists[sListName];</pre>
<pre>string sFinalCaml = replaceListGuidString(sFieldElement, sListName, referencedList);
 //createLookupColumn(currentWeb, sFinalCaml, sListName);
 //CORRECTED ABOVE BECAUSE LIST NAME WAS BEING PASSED IN INTEAD OF COLUMN NAME
 createLookupColumn(currentWeb, sFinalCaml, sColumnName);
 }
 }</pre>
<pre>nReader.Close();</pre>
<pre>}</pre>
<pre>}
 }
 }</pre>
<pre>private string replaceListGuidString(string sFieldElement, string sListName, SPList referencedList)
 {
 string sListWithName = string.Format("List="{0}"", sListName);
 string sListWithGuid = string.Format("List="{{{0}}}"", referencedList.ID);
 return sFieldElement.Replace(sListWithName, sListWithGuid);
 }</pre>
<pre>///
 /// Attempt to delete the column. Note that this will fail if the column is in use,
 /// i.e. it is used in a content type or list. I prefer to not catch the exception
 /// (though it may be useful to add extra logging), hence feature deactivation/re-activation
 /// will fail. This effectively means this feature cannot be deactivated whilst the column
 /// is in use.
 ///
 ///
 Column to delete.   private void attemptColumnDelete(SPWeb web, string sColumnName)
 {
 SPFieldLookup lookupColumn = null;</pre>
<pre>// we don't care if there was an exception retrieving the field from the collection,
 // since if it's not there we can't delete it anyway..
 try
 {
 lookupColumn = web.Fields.GetFieldByInternalName(sColumnName) as SPFieldLookup;
 }
 catch (ArgumentException argExc)
 {</pre>
<pre>}</pre>
<pre>if (lookupColumn != null)
 {
 try
 {
 lookupColumn.Delete();
 }
 catch (SPException SpExc)
 {
 // consider logging full explanation..</pre>
<pre>throw;
 }
 }
 }</pre>
<pre>private void createLookupColumn(SPWeb web, string sColumnDefinitionXml, string sColumnName)
 {
 // delete the column if it exists already and is not yet in use..
 attemptColumnDelete(web, sColumnName);</pre>
<pre>SPFieldLookup lookupColumn = null;</pre>
<pre>// now create the column from the CAML definition..
 string sCreatedColName = web.Fields.AddFieldAsXml(sColumnDefinitionXml);</pre>
<pre>// also set LookupWebId so column can be used in webs other than web which hosts list..
 //lookupColumn = web.Fields[sCreatedColName] as SPFieldLookup;
 //CORRECTED ABOVE LINE:
 lookupColumn = web.Fields.GetFieldByInternalName(sCreatedColName) as SPFieldLookup;
 lookupColumn.LookupWebId = web.Site.RootWeb.ID;
 lookupColumn.Update();
 }</pre>
<pre>private void CleanupLookupColumns(SPFeatureReceiverProperties properties)
 {
 // delete the column if it exists already and is not yet in use..</pre>
<pre>// feature is scoped at Site, so the parent is type SPSite rather than SPWeb..
 using (SPSite site = properties.Feature.Parent as SPSite)
 {
 SPWeb currentWeb = null;
 Guid gRootWebId = Guid.Empty;
 if (site != null)
 {
 currentWeb = site.RootWeb;
 gRootWebId = currentWeb.ID;
 }
 else
 {
 currentWeb = properties.Feature.Parent as SPWeb;
 gRootWebId = currentWeb.Site.RootWeb.ID;
 }</pre>
<pre>using (currentWeb)
 {
 string sColumnName = null;</pre>
<pre>SPElementDefinitionCollection coll =
 properties.Feature.Definition.GetElementDefinitions(System.Globalization.CultureInfo.CurrentCulture);
 foreach (SPElementDefinition def in coll)
 {
 XmlNode node = def.XmlDefinition;
 XmlNodeReader nReader = new XmlNodeReader(node);
 while (nReader.Read())
 {
 if (nReader.LocalName == "Field")
 {
 //check to see if this is a lookup field
 if (nReader.MoveToAttribute("Type"))
 {
 string type = nReader.Value;
 nReader.MoveToElement();
 if (type.ToLower() != "lookup" &amp;&amp; type.ToLower() != "lookupmulti")
 continue;
 }</pre>
<pre>if (nReader.MoveToAttribute("Name"))
 {
 sColumnName = nReader.Value;
 nReader.MoveToElement();
 }</pre>
<pre>attemptColumnDelete(currentWeb, sColumnName);
 }
 }</pre>
<pre>nReader.Close();
 }
 }
 }
 }
 }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mexicanratdog.com/2007/10/01/create-lookup-site-columns-target-lists-through-a-feature/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

