<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Andy Burns' SharePoint Blog</title>
	
	<link>http://www.novolocus.com</link>
	<description>Whatever I'm working on, really...</description>
	<lastBuildDate>Thu, 09 May 2013 13:53:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/novolocus" /><feedburner:info uri="novolocus" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>novolocus</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Setting the Title field for Content Types</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/ObbNtZz3Gz4/</link>
		<comments>http://www.novolocus.com/2013/05/09/setting-the-title-field-for-content-types/#comments</comments>
		<pubDate>Thu, 09 May 2013 13:53:23 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[SPContentType]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2580</guid>
		<description><![CDATA[This is one I&#8217;ve been meaning to blog about for a while. I was using a Content Type where I was trying to set the display name of &#8216;Title&#8217; field. I was happy to have a Title column, but I &#8230; <a href="http://www.novolocus.com/2013/05/09/setting-the-title-field-for-content-types/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is one I&#8217;ve been meaning to blog about for a while. I was using a Content Type where I was trying to set the display name of &#8216;Title&#8217; field. I was happy to have a Title column, but I wanted it to have a different name.</p>
<p>I tried doing this declaratively:</p>
<pre class="brush: xml; title: ; notranslate">&lt;FieldRef ID=&quot;{fa564e0f-0c70-4ab9-b863-0177e6ddd247}&quot; Name=&quot;Title&quot; DisplayName=&quot;Request&quot; Required=&quot;FALSE&quot; /&gt;</pre>
<p>However, I found this didn&#8217;t work in SP2010 &#8211; the field still appeared as &#8216;Title&#8217;. This was frustrating.</p>
<p>Instead, I had to set the Title&#8217;s display name in code:</p>
<pre class="brush: csharp; title: ; notranslate">foreach (SPFieldLink fldLnk in contentType.FieldLinks)
{
if (fldLnk.Id == SPBuiltInFieldId.Title)
{
fldLnk.DisplayName = &quot;Request&quot;;
}
}
contentType.Update(false);</pre>
<p>This was a bit strange &#8211; other fields can have a DisplayName set in CAML quite happily. This seems to just be a feature of the Title column.</p>
<p><strong>EDIT:</strong> I also had to use a similar approach on setting the Title column for a content type used on a list &#8211; but using:</p>
<pre class="brush: csharp; title: ; notranslate">private void SetTitleField(SPWeb web, string listname, string contentTypeName, string newTitleName) 
{
SPList list = web.Lists[listname];
SPContentType ct = list.ContentTypes[contentTypeName];

foreach (SPFieldLink fldLnk in ct.FieldLinks)
{
//Necessary to set title field - when using content types, this seems to set it to &quot;Title&quot; irrespective of what is set in the Content type or list's XML.
if (fldLnk.Id == SPBuiltInFieldId.Title)
{
	fldLnk.DisplayName = newTitleName;
	ct.Update(false);
	break;
}
}
foreach (SPField fld in list.Fields)
{
if (fld.Id == SPBuiltInFieldId.Title)
{
	fld.Title = newTitleName;
	fld.Update();
	break;
}
}     
}</pre>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/ObbNtZz3Gz4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2013/05/09/setting-the-title-field-for-content-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2013/05/09/setting-the-title-field-for-content-types/</feedburner:origLink></item>
		<item>
		<title>Query Throttling in SharePoint 2013</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/AOAb3CV6dG0/</link>
		<comments>http://www.novolocus.com/2013/04/26/query-throttling-in-sharepoint-2013/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 09:57:30 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2013]]></category>
		<category><![CDATA[Large Lists]]></category>
		<category><![CDATA[QueryThrottling]]></category>
		<category><![CDATA[SPQuery]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2576</guid>
		<description><![CDATA[So, last week I was at the #SPEvo13 conference in London, and one innocuous session by Wayne Ewington sent shivers down my spine &#8211; about query throttling. So, what is query throttling again, and why did it was I worried? &#8230; <a href="http://www.novolocus.com/2013/04/26/query-throttling-in-sharepoint-2013/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>So, last week I was at the #SPEvo13 conference in London, and one innocuous session by Wayne Ewington sent shivers down my spine &#8211; about query throttling. So, what is query throttling again, and why did it was I worried?<span id="more-2576"></span></p>
<p>Well, fundamentally the issue is inefficient queries being run against SharePoint lists. An inefficient query against a list with a small number of items isn’t a big deal, but with larger lists (over 5000 items) SQL server has to escalate from a row-level lock to a table-level lock. This can hold up other users while the table is locked, and could be very slow. To overcome this, SharePoint rejects queries that breach it&#8217;s rules with a <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquerythrottledexception.aspx" target="_blank">SPQueryThrottledException</a>. Fine, but what are the factors in determining if it&#8217;s throttled? Well, that&#8217;s kind of complicated. You&#8217;ve got the following factors:</p>
<ul>
<li><strong>Indexed Columns</strong> &#8211; An index makes it more likely that the query will succeed &#8211; &#8216;cos it doesn&#8217;t have to scan the whole List. You can still get an exception if your eventual results set is more than 5000 items. An Index on a Unique valued column will always pass, though.</li>
<li><strong>Query Throttle Limit</strong> &#8211; you can adjust this value from 5000 items &#8211; but Microsoft did chose that value for a reason. Beware!</li>
<li><strong>Who is querying?</strong> <span style="text-decoration: underline;">Ordinary users</span> have one limit (normally 5000 items), <span style="text-decoration: underline;">Super users</span> (users with Read or Full Control on the entire web app) a second limit, and <span style="text-decoration: underline;">Farm Admins</span> are unlimited. <em>Note that as developers typically develop using a Farm Admin account, this is risky, and means careful testing with other accounts and real volumes of data is necessary</em>. Also not that <span style="text-decoration: underline;">App Pool</span> accounts are still limited &#8211; Elevating privileges will not avoid query throttling. And <span style="text-decoration: underline;">Site Collection Admins</span> are also still limited.</li>
<li><strong>How you&#8217;re querying</strong> &#8211; There are some ways around these limits by getting the results in blocks, <a href="http://www.novolocus.com/2012/07/13/dealing-with-large-lists-part-3-the-contentiterator/">using the <strong>ContentIterator</strong> control</a>.</li>
<li><strong>Overrides</strong> &#8211; You can allow code to override your query throttle limits on a web app.</li>
<li><strong>&#8220;Happy Hour&#8221;</strong> &#8211; You can set a period (normally of low usage) where query throttle limits are turned off &#8211; for example, in the middle of the night, if you need to do reports or something.</li>
<li><strong>Authentication Method</strong> &#8211; New for SharePoint 2013, the Query Throttle limits are different if you use Classic or Claims authentication. Yup, the authentication mode matters. This came as something of a surprise to both Wayne and myself, and sent a shiver through me; I had visions of some of my applications not working&#8230;</li>
<li><strong>Query Throttling on External Lists</strong> &#8211; Not something I&#8217;d thought of before, but if your BCS connection limits the number of items it returns to a limit <em>below</em> the Query Throttle limit then even if your query on the external list should return more than that limit, you&#8217;ll only get the number specified by BCS, and the Query Throttle won&#8217;t be hit. In other words, the BCS limit is applied before the Query Throttle limit. Or so Wayne says &#8211; it&#8217;s not something I&#8217;ve tried.</li>
</ul>
<p>So, not simple. I did ask if there was a document or a table of this stuff, but apparently there isn&#8217;t :/ . This is unfortunate; I feel this whole area is unnecessarily complex, and Wayne&#8217;s session was largely a set of questions to see what the audience knew &#8211; and it turns out that an audience of largely SharePoint devs were confused by it &#8230;</p>
<p>I guess, therefore, test, and test again, and remember to deal with large lists&#8230;</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/AOAb3CV6dG0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2013/04/26/query-throttling-in-sharepoint-2013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2013/04/26/query-throttling-in-sharepoint-2013/</feedburner:origLink></item>
		<item>
		<title>Refinements panel and Custom Search Box web parts</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/7JS2iuj_TPM/</link>
		<comments>http://www.novolocus.com/2013/04/24/refinements-panel-and-custom-search-box-web-parts/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 09:03:26 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Search 2010]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2570</guid>
		<description><![CDATA[So I&#8217;m doing some work for a customer where they want a custom Search Box web part. Essentially, they want to be able to search by particular managed properties, which is a pretty common scenario: Naturally, I added this to &#8230; <a href="http://www.novolocus.com/2013/04/24/refinements-panel-and-custom-search-box-web-parts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>So I&#8217;m doing some work for a customer where they want a custom Search Box web part. Essentially, they want to be able to search by particular managed properties, which is a pretty common scenario:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2013/04/Capture.png"><img class="aligncenter size-medium wp-image-2571" alt="Capture" src="http://www.novolocus.com/wp-content/uploads/2013/04/Capture-300x130.png" width="300" height="130" /></a>Naturally, I added this to my search results page, and removed the existing Search Box web part.</p>
<p>During test, the customer noticed that the &#8216;Show More&#8217; links on the refinement panel had stopped working:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2013/04/Capture2.png"><img class="aligncenter size-full wp-image-2573" alt="Capture2" src="http://www.novolocus.com/wp-content/uploads/2013/04/Capture2.png" width="193" height="165" /></a>Interesting &#8211; although showing some different metadata properties, this was all pretty standard stuff. A bit of a check on Google found <a href="http://blogs.visigo.com/chriscoulson/search-refinement-panel-web-part-show-more-link-not-working/">this interesting post by Chris Coulson</a>. The short if it is that the Refinements panel uses JavaScript that is loaded by the Search Box web part &#8211; so you have to have a Search Box web part on the results page, even if it is hidden. Add that and the Refinement panel works again.</p>
<p>You can hide the web part via the web part properties &gt; Layout &gt; Hidden.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/7JS2iuj_TPM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2013/04/24/refinements-panel-and-custom-search-box-web-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2013/04/24/refinements-panel-and-custom-search-box-web-parts/</feedburner:origLink></item>
		<item>
		<title>The Importance of knowing Regular Expressions</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/PeB1QTwhoiU/</link>
		<comments>http://www.novolocus.com/2013/01/12/the-importance-of-knowing-regular-expressions/#comments</comments>
		<pubDate>Sat, 12 Jan 2013 15:37:11 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2557</guid>
		<description><![CDATA[It&#8217;s something that always mystifies me, it does seem that a lot of developers don&#8217;t know regular expression syntax very well. This came up when I was on some SharePoint 2013 training just before Christmas. SharePoint 2013 introduces something called &#8230; <a href="http://www.novolocus.com/2013/01/12/the-importance-of-knowing-regular-expressions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s something that always mystifies me, it does seem that a lot of developers don&#8217;t know regular expression syntax very well. This came up when I was on some SharePoint 2013 training just before Christmas.</p>
<p>SharePoint 2013 introduces something called &#8220;Routing Rules&#8221;. These are rules that allow you to direct traffic to different front-end servers (or pools of servers), allowing you to isolate traffic, route to better health servers, etc.. Spence Harbar has <a href="http://www.harbar.net/articles/sp2013rm1.aspx">a very good article about it</a>.</p>
<p>Anyway, one some of the criteria that you can match rules on are Regular Expressions. However, SharePoint does warn you that Regex routing rules are slower &#8211; this is unsurprising. But how much slower than, say, a &#8216;Starts with&#8217; or &#8216;Ends with&#8217; rule? And on the Ignite training I did wonder about the efficiency of their example&#8230;<span id="more-2557"></span></p>
<p>To test this I made some assumptions. First, I&#8217;m guessing that the record routing rules are written in C#, secondly, that the use the normal C# regex engine. Thirdly, I&#8217;ll assume that the &#8216;Ends With&#8217; and &#8216;Starts with&#8217; rules use the ordinary <a href="http://msdn.microsoft.com/en-us/library/system.string.aspx"><strong>String</strong> </a>class methods. If so, this would mean I could test the relative speed of the different rules, and perhaps whether the example from the training was a particularly efficient one.</p>
<p>I wrote a little console app, and contrived a test string of:</p>
<pre class="brush: csharp; title: ; notranslate">string target = &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMicrosoft One Note 2010&quot;;</pre>
<p>I chose this because I wanted to try the Ignite example regex, which should match faster if the target string is at the end of the input:</p>
<pre class="brush: csharp; title: ; notranslate"> Regex igniteRegex = new Regex(&quot;.*Microsoft One Note 2010*&quot;);</pre>
<p><a href="http://www.regexper.com/">Regexper </a>nicely resolves this to:</p>
<p><img class="aligncenter size-full wp-image-2558" alt="regex" src="http://www.novolocus.com/wp-content/uploads/2013/01/regex.png" width="427" height="64" /></p>
<p>Cool. Now, the way regex engines match statements like <strong>.*</strong> is that, as they build up a stack of matching characters, this would make them capture the whole string to the end, and then they&#8217;d pop each character off the stack until it can match the next part of the regex.</p>
<p>My belief was that a simpler regex, such as:</p>
<pre class="brush: csharp; title: ; notranslate"> Regex igniteRegex = new Regex(&quot;Microsoft One Note 2010&quot;);</pre>
<p>Would be faster. This wouldn&#8217;t need to &#8216;scan backwards&#8217; over the string. It&#8217;s also, notably, much less obviously a Regex &#8211; there&#8217;s no character classes, or operators to match multiple characters, etc.. Effectively, we&#8217;re just looking for that text within the string.</p>
<p>And, finally, I&#8217;d test an &#8216;Ends With&#8217; using the <strong>String.EndsWith()</strong> method.</p>
<p>I&#8217;d try matches with each of these on the target string 1,000,000 times, to take a decent amount of time. So, the results?</p>
<p><img class="aligncenter size-full wp-image-2559" alt="results" src="http://www.novolocus.com/wp-content/uploads/2013/01/results.png" width="298" height="47" /></p>
<p>Yup, that&#8217;s right &#8211; changing the regex save about 60% of the time, and using <strong>EndsWith()</strong> was 30% faster than that, too.</p>
<p>I&#8217;ve no doubt that the regex used in the training was just an example, but what concerned me a little was that, as I said at the start, I&#8217;m frequently surprised by how unfamiliar some developers are with regexes, and I&#8217;m not sure it was made clear enough the impact of the regex pattern. I mean, I wouldn&#8217;t have thought such small changes would make such a large difference.</p>
<p>Now, obviously this test is still a bit contrived. If I was putting this into production I think I&#8217;d be tempted to try to get a sample of the URLs I&#8217;d wanted to process &#8211; both items I wanted to match and not match &#8211; and then, similarly to above, I&#8217;d write a little console application to check my regex against them. I mean, the savings we&#8217;re talking about are tiny, but are for each request, and are comparatively easy.</p>
<p>Conclusion &#8211; design your regexes with care if using Routing Rules in SharePoint.</p>
<p><strong>Additional:</strong> Charlie (see below) asks a good question &#8211; how does &#8220;Ends With&#8221; compare with a regex that matches &#8216;End String&#8217; (i.e. $ ). My gut feel was that this would still be slower than without, but barely. The reasoning behind this was that the regex would still scan forward over the whole string until it found a match. EndsWith() is probably optimised for simply checking the tail. The most likely thing to upset this logic is if the Regex engine has an optimisation to realise that <em>&#8216;something$</em>&#8216; is equivalent to <em>EndsWith(&#8220;something&#8221;) </em>and so does that instead. My results?</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2013/01/Capture.png"><img class="aligncenter size-medium wp-image-2563" alt="Capture" src="http://www.novolocus.com/wp-content/uploads/2013/01/Capture-300x64.png" width="300" height="64" /></a>So you can see that the &#8216;End String&#8217; character doesn&#8217;t make much difference in speed &#8211; less than 5% &#8211; which suggests that that string is still scanned forward.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/PeB1QTwhoiU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2013/01/12/the-importance-of-knowing-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2013/01/12/the-importance-of-knowing-regular-expressions/</feedburner:origLink></item>
		<item>
		<title>Add a batch file to Windows 8 Start Menu</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/uHY5g8MYeDQ/</link>
		<comments>http://www.novolocus.com/2012/12/03/add-a-batch-file-to-windows-8-start-menu/#comments</comments>
		<pubDate>Mon, 03 Dec 2012 12:47:45 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Windows8]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2551</guid>
		<description><![CDATA[Okay &#8211; maybe I&#8217;m old school, but I still find batch files useful, so it&#8217;s annoying (one of many annoyances) that in Windows 8 you can&#8217;t pin them to the new start menu. Well, fortunately, Flavien Charlon has the answer. &#8230; <a href="http://www.novolocus.com/2012/12/03/add-a-batch-file-to-windows-8-start-menu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Okay &#8211; maybe I&#8217;m old school, but I still find batch files useful, so it&#8217;s annoying (one of many annoyances) that in Windows 8 you can&#8217;t pin them to the new start menu.</p>
<p>Well, fortunately, Flavien Charlon <a href="http://blogs.msdn.com/b/flaviencharlon/archive/2012/11/08/pin-any-executable-to-the-windows-8-start-screen.aspx">has the answer</a>. Put a shortcut to your batch file in <strong>%ProgramData%\Microsoft\Windows\Start Menu\Programs</strong></p>
<p>You should then be able to add it from &#8216;All Apps&#8217; on the start menu.</p>
<p>That&#8217;s one annoyance dealt with. Sadly, Windows 8 seems to have plenty more.</p>
<blockquote><p>&#8220;I got 99 problems but a batch ain&#8217;t one&#8221;</p></blockquote>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/uHY5g8MYeDQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/12/03/add-a-batch-file-to-windows-8-start-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/12/03/add-a-batch-file-to-windows-8-start-menu/</feedburner:origLink></item>
		<item>
		<title>Annoying Exporting a list to Excel</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/Xos5qJ_8zRU/</link>
		<comments>http://www.novolocus.com/2012/11/21/annoying-exporting-a-list-to-excel/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 13:36:28 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Admin 2010]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Lists]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2543</guid>
		<description><![CDATA[SharePoint lists have the ability to export their contents to an Excel Workbook. This is quite cute &#8211; it gives the users a way to get the data out into something they&#8217;re familiar with, can manipulate and can print. However, &#8230; <a href="http://www.novolocus.com/2012/11/21/annoying-exporting-a-list-to-excel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>SharePoint lists have the ability to export their contents to an Excel Workbook.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/11/Export-to-Excel.png"><img class="aligncenter size-medium wp-image-2545" title="Export to Excel" src="http://www.novolocus.com/wp-content/uploads/2012/11/Export-to-Excel-300x91.png" alt="" width="300" height="91" /></a></p>
<p>This is quite cute &#8211; it gives the users a way to get the data out into something they&#8217;re familiar with, can manipulate and can print. However, I was having an issue. Using a list based on a Custom List (above), one of my columns (Enquiry) wasn&#8217;t exported:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/11/Excel-Export.png"><img class="aligncenter size-medium wp-image-2544" title="Excel Export" src="http://www.novolocus.com/wp-content/uploads/2012/11/Excel-Export-300x92.png" alt="" width="300" height="92" /></a></p>
<p>I wondered at first if this was because of it&#8217;s column type (Hyperlink), or because I&#8217;d created the column programmatically. Then, on a hunch really, I tried changing the column order. I added another column before it in the list view. I used the ID column, but any should work. When I exported the list &#8211; all the columns I wanted came through (but the ID column didn&#8217;t).</p>
<p>What I think is going on here is that if you used the same export on a document library then typically &#8211; though not always &#8211; the first column is an icon for the type of file it is. My suspicion is that some muppet, when writing the export to excel, realised that they&#8217;d have these icons, and decided to avoid them by excluding the first column. This is unfortunate for two reasons:</p>
<ul>
<li>Not all lists have icons &#8211; witness my Custom List</li>
<li>Not all document libraries have the file icon as the first column.</li>
</ul>
<p>For now the resolution would be to have another column as the first on your list.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/Xos5qJ_8zRU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/11/21/annoying-exporting-a-list-to-excel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/11/21/annoying-exporting-a-list-to-excel/</feedburner:origLink></item>
		<item>
		<title>BeforeProperties and AfterProperties</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/B6wBLrBATxY/</link>
		<comments>http://www.novolocus.com/2012/11/21/beforeproperties-and-afterproperties/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 10:11:07 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Event Receivers]]></category>
		<category><![CDATA[SPItemEventReceiver]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2538</guid>
		<description><![CDATA[I am sick of having to hunt down the link to Synergy&#8217;s post on the BeforeProperties and AfterProperties available in different events on SPListItems. For my reference, here it is: List: List BeforeProperties AfterProperties properties.ListItem ItemAdding No value New value &#8230; <a href="http://www.novolocus.com/2012/11/21/beforeproperties-and-afterproperties/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I am <em>sick</em> of having to hunt down the link to <a href="http://www.synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=122">Synergy&#8217;s post </a>on the BeforeProperties and AfterProperties available in different events on SPListItems. For my reference, here it is:</p>
<p><strong>List:</strong></p>
<table width="100%" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td><strong>List</strong></td>
<td><strong>BeforeProperties</strong></td>
<td><strong>AfterProperties</strong></td>
<td><strong>properties.ListItem</strong></td>
</tr>
<tr>
<td>ItemAdding</td>
<td>No value</td>
<td>New value</td>
<td>Null</td>
</tr>
<tr>
<td>ItemAdded</td>
<td>No value</td>
<td>New value</td>
<td>New value</td>
</tr>
<tr>
<td>ItemUpdating</td>
<td>No value</td>
<td>Changed value</td>
<td>Original value</td>
</tr>
<tr>
<td>ItemUpdated</td>
<td>No value</td>
<td>Changed value</td>
<td>Changed value</td>
</tr>
<tr>
<td>ItemDeleting</td>
<td>No value</td>
<td>No value</td>
<td>Original value</td>
</tr>
<tr>
<td>ItemDeleted</td>
<td>No value</td>
<td>No value</td>
<td>Null</td>
</tr>
</tbody>
</table>
<p><strong> Document Library:</strong></p>
<table width="25%" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td><strong>Library</strong></td>
<td><strong>BeforeProperties</strong></td>
<td><strong>AfterProperties</strong></td>
<td><strong>properties.ListItem</strong></td>
</tr>
<tr>
<td>ItemAdding</td>
<td>No value</td>
<td>No value</td>
<td>Null</td>
</tr>
<tr>
<td>ItemAdded</td>
<td>No value</td>
<td>No value</td>
<td>New value</td>
</tr>
<tr>
<td>ItemUpdating</td>
<td>Original value</td>
<td>Changed value</td>
<td>Original value</td>
</tr>
<tr>
<td>ItemUpdated</td>
<td>Original value</td>
<td>Changed value</td>
<td>Changed value</td>
</tr>
<tr>
<td>ItemDeleting</td>
<td>No value</td>
<td>No value</td>
<td>Original value</td>
</tr>
<tr>
<td>ItemDeleted</td>
<td>No value</td>
<td>No value</td>
<td>Null</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> Allegedly, this <a href="http://blog.ray1.net/2011/06/getting-beforeproperties-and.html">does change if the event receiver is synchronous </a>- the before properties are available. I&#8217;ve not checked this out yet.</p>
<p>Obviously, for SharePoint 2007 systems that doesn&#8217;t apply &#8211; as &#8216;*ed&#8217; event receivers are always asynchronous.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/B6wBLrBATxY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/11/21/beforeproperties-and-afterproperties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/11/21/beforeproperties-and-afterproperties/</feedburner:origLink></item>
		<item>
		<title>ContentIterator – Curious Behaviour, and Infinite looping</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/r1kAYBSRZNI/</link>
		<comments>http://www.novolocus.com/2012/11/01/contentiterator-curious-behaviour-and-infinite-looping/#comments</comments>
		<pubDate>Thu, 01 Nov 2012 13:05:07 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[ContentIterator]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2534</guid>
		<description><![CDATA[I like the ContentIterator control &#8211; it&#8217;s a nice way of being able to process a lot of items in SharePoint. However, sometimes it&#8217;s behaviour is &#8230; strange. I had been using it to loop over some (but not all) the &#8230; <a href="http://www.novolocus.com/2012/11/01/contentiterator-curious-behaviour-and-infinite-looping/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I like the <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.utilities.contentiterator.aspx"><strong>ContentIterator</strong></a> control &#8211; it&#8217;s a nice way of being able to process a <em>lot</em> of items in SharePoint. However, sometimes it&#8217;s behaviour is &#8230; strange.</p>
<p>I had been using it to loop over some (but not all) the items in a list. Some changes meant that I was now going to loop over all the items. I had a list with 500 items that I was testing with. My code was:</p>
<pre class="brush: csharp; title: ; notranslate">ContentIterator ci = new ContentIterator(&quot;example&quot;);
SPQuery qry = new SPQuery();
qry.Query = ContentIterator.ItemEnumerationOrderByNVPField;
ci.ProcessListItems(list,qry, ProcessItem, ProcessItemError);</pre>
<p>This would process the first 200 items, over and over. It never reached an end. Hmm.<span id="more-2534"></span></p>
<p>I was puzzled by this, so I put my code in a console app, and then tried querying the list (to check the number of items I was getting):</p>
<pre class="brush: csharp; title: ; notranslate">ContentIterator ci = new ContentIterator(&quot;Replicate&quot;);
SPQuery qry = new SPQuery();
qry.Query = ContentIterator.ItemEnumerationOrderByNVPField;
Console.WriteLine(qry.Query);
SPListItemCollection items = list.GetItems(qry);
Console.WriteLine(&quot;Item: {0}&quot;, items.Count);
ci.ProcessListItems(list,qry, ProcessItem, ProcessItemError);</pre>
<p>Interestingly, this worked. I can&#8217;t see <em>why</em> though. I presume that using the <strong>SPQuery</strong> changes the query, or somehow affects the list. I&#8217;m really not sure.</p>
<p>Now, the observant might well note that actually, a better overload to use on the <strong><a href="http://msdn.microsoft.com/en-us/library/ee568192.aspx">ContentIterator.ProcessListItems</a></strong> would be the one that doesn&#8217;t need a query:</p>
<pre class="brush: csharp; title: ; notranslate">ci.ProcessListItems(list, ProcessItem, ProcessItemError);</pre>
<p>This made me wonder &#8211; what was different about this? Well, I used Reflector and looked within the class, and found that it was using a different OrderBy clause. When I changed my code to&#8230;</p>
<pre class="brush: csharp; title: ; notranslate">ContentIterator ci = new ContentIterator(&quot;example&quot;);
SPQuery qry = new SPQuery();
qry.Query = ContentIterator.ItemEnumerationOrderByID;
ci.ProcessListItems(list,qry, ProcessItem, ProcessItemError);</pre>
<p>&#8230; it worked.</p>
<p>So, if your <strong>ContentIterator</strong> starts to run forever:</p>
<ul>
<li>Check you&#8217;re using the best overload for what you want. If you don&#8217;t need to use an <strong>SPQuery</strong>, don&#8217;t!</li>
<li>Check your Order By clause &#8211; you may need to use a different one.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/r1kAYBSRZNI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/11/01/contentiterator-curious-behaviour-and-infinite-looping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/11/01/contentiterator-curious-behaviour-and-infinite-looping/</feedburner:origLink></item>
		<item>
		<title>Exchange Tasks integration with iOS and OSx</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/s9NAk2dD4QE/</link>
		<comments>http://www.novolocus.com/2012/10/19/exchange-tasks-integration-with-ios-and-osx/#comments</comments>
		<pubDate>Fri, 19 Oct 2012 06:54:37 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[OSx]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Outlook]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2528</guid>
		<description><![CDATA[Outlook has Tasks. I tend to flag emails that I need to take further action on, and they appear in my tasks list in Exchange: iOS 5 and OSx (Mountain Lion or later) have ‘Reminders’. I figured that it must &#8230; <a href="http://www.novolocus.com/2012/10/19/exchange-tasks-integration-with-ios-and-osx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Outlook has Tasks. I tend to flag emails that I need to take further action on, and they appear in my tasks list in Exchange:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/10/Capture.png"><img class="aligncenter size-medium wp-image-2530" title="Capture" src="http://www.novolocus.com/wp-content/uploads/2012/10/Capture-115x300.png" alt="" width="115" height="300" /></a></p>
<p>iOS 5 and OSx (Mountain Lion or later) have ‘Reminders’. I figured that it must be possible to show Tasks from Exchange – after all, I could already sync Email and Calendars. So I set this up … and no tasks came through. Puzzling.<span id="more-2528"></span></p>
<p>Instead, I tried the opposite – to create an Exchange Task from iOS.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/10/iPhone.png"><img class="aligncenter size-full wp-image-2529" title="iPhone" src="http://www.novolocus.com/wp-content/uploads/2012/10/iPhone.png" alt="" width="200" height="300" /></a></p>
<p>These tasks then did appear in Outlook. It was only then that I went to the Outlook ‘Tasks’ tab, and realised that only the tasks created as ‘Tasks’ were being synchronised. Check out the ‘type’ icons. &#8216;Followed up&#8217; email has a mail icon &#8211; and the tasks that sync have a &#8216;Task&#8217; icon:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/10/Capture2.png"><img class="aligncenter size-medium wp-image-2531" title="Capture2" src="http://www.novolocus.com/wp-content/uploads/2012/10/Capture2-300x176.png" alt="" width="300" height="176" /></a></p>
<p>I created a ‘Task’ item in Outlook and voila, it appeared on my phone (as you can see in the screenshot of my phone).</p>
<p>Further checking shows that <strong>when you flag an item for ‘Follow Up’, it creates a ‘To Do’ item. This is not the same as a Task, and isn’t synced with iOS or Mac OSx Reminders</strong>.</p>
<p>It’s kinda hard to say who missed the point here – Microsoft or Apple – but it is pretty annoying that an email flagged for follow up can’t be synced with Reminders. This might be worth remembering if considering Office 365 / iPad or iPhone scenarios.</p>
<p>(Other than that, it’s nice to be able to get email, contact and calendar information by phone)</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/s9NAk2dD4QE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/19/exchange-tasks-integration-with-ios-and-osx/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/19/exchange-tasks-integration-with-ios-and-osx/</feedburner:origLink></item>
		<item>
		<title>HTML 5 – Email Address Validation Regex</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/CjUFurNRWcw/</link>
		<comments>http://www.novolocus.com/2012/10/18/html-5-email-address-validation-regex/#comments</comments>
		<pubDate>Thu, 18 Oct 2012 10:51:33 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2514</guid>
		<description><![CDATA[And interesting one to stumble upon &#8211; the &#8216;official&#8216; regex for validating a email address: Edit: I&#8217;ve had to break this down into parts &#8211; for some reason WordPress throws a 403 error if I don&#8217;t. I think it sees &#8230; <a href="http://www.novolocus.com/2012/10/18/html-5-email-address-validation-regex/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>And interesting one to stumble upon &#8211; the &#8216;<a href="http://www.w3.org/TR/html5/states-of-the-type-attribute.html#valid-e-mail-address">official</a>&#8216; regex for validating a email address:</p>
<p><strong>Edit:</strong> I&#8217;ve had to break this down into parts &#8211; for some reason WordPress throws a 403 error if I don&#8217;t. I think it sees this regex as a security risk!</p>
<p>Before the @ sign:<br />
^[a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+</p>
<p>The @ sign and after:<br />
@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$</p>
<p>Reads like it should work pretty well to me. I didn&#8217;t realise before the @ was so generous. And you could shrink it by using a case insensitive operator.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/CjUFurNRWcw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/18/html-5-email-address-validation-regex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/18/html-5-email-address-validation-regex/</feedburner:origLink></item>
		<item>
		<title>Select AirPlay from Volume Control</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/9AVBrcy8pe8/</link>
		<comments>http://www.novolocus.com/2012/10/12/select-airplay-from-volume-control/#comments</comments>
		<pubDate>Fri, 12 Oct 2012 09:04:23 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[OSx]]></category>
		<category><![CDATA[AirPlay]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2508</guid>
		<description><![CDATA[From Mac OSx Hints: If you have the Volume menu visible in the menu bar, clicking on this icon displays a simple volume slider. But if you hold the Option key when you click on the icon, you can select &#8230; <a href="http://www.novolocus.com/2012/10/12/select-airplay-from-volume-control/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>From Mac OSx Hints:</p>
<blockquote><p>If you have the Volume menu visible in the menu bar, clicking on this icon displays a simple volume slider. But if you hold the Option key when you click on the icon, you can select audio inputs and outputs directly, including nearby devices compatible with AirPlay.</p></blockquote>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/9AVBrcy8pe8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/12/select-airplay-from-volume-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/12/select-airplay-from-volume-control/</feedburner:origLink></item>
		<item>
		<title>Delete Event Receiver from a Content Type with Code</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/m3OvrEhpck4/</link>
		<comments>http://www.novolocus.com/2012/10/10/delete-event-receiver-from-a-content-type-with-code/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 15:50:49 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Content Type]]></category>
		<category><![CDATA[Event Receivers]]></category>
		<category><![CDATA[SPContentType]]></category>
		<category><![CDATA[SPItemEventReceiver]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2510</guid>
		<description><![CDATA[SharePoint allows you to attach event receivers to content types. That&#8217;s pretty handy. Unfortunately, deleting event receivers from those content types is much more hard. Perhaps this is why the Document ID feature fails to remove the content types that &#8230; <a href="http://www.novolocus.com/2012/10/10/delete-event-receiver-from-a-content-type-with-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>SharePoint allows you to attach event receivers to content types. That&#8217;s pretty handy. Unfortunately, deleting event receivers from those content types is much more hard. Perhaps this is why the Document ID feature fails to remove the content types that it adds. However, here is one possible approach.</p>
<pre class="brush: csharp; title: ; notranslate">SPContentType ctype = site.RootWeb.ContentTypes[SPBuiltInContentTypeId.Document];
if (ctype != null)
{
 if (ctype.EventReceivers != null)
 {
   bool bContinueDelete = true;
   while (bContinueDelete)
   {
     if (ctype.EventReceivers.Count &lt; 1)
     {
       bContinueDelete = false;
     }
     else
     {
     bool bFoundOne = false;
     foreach (SPEventReceiverDefinition d in ctype.EventReceivers)
     {
         //Could match on the Type of the event receiver, but for this example, let's use name
         if (d.Name.Contains(&quot;Document ID&quot;))
         {
           d.Delete();
           ctype.Update(true, false);
           bFoundOne = true;
           break;
         }
     }
     if (!bFoundOne)
     {
       bContinueDelete = false;
     }
   }
 }
}</pre>
<p>More on why this is important in a later post.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/m3OvrEhpck4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/10/delete-event-receiver-from-a-content-type-with-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/10/delete-event-receiver-from-a-content-type-with-code/</feedburner:origLink></item>
		<item>
		<title>Change Default Save Location from iCloud</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/jst-_mls-00/</link>
		<comments>http://www.novolocus.com/2012/10/09/change-default-save-location-from-icloud/#comments</comments>
		<pubDate>Tue, 09 Oct 2012 09:04:13 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[OSx]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2506</guid>
		<description><![CDATA[This is a note for myself, found on Mac OSx Hints. I don&#8217;t like the iCloud UI for OSx &#8211; it&#8217;s inferior to Dropbox. As each  application has it&#8217;s own iCloud storage it&#8217;s pretty hard to store a heterogeneous set of documents &#8230; <a href="http://www.novolocus.com/2012/10/09/change-default-save-location-from-icloud/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This is a note for myself, found on <a href="http://hints.macworld.com/article.php?story=20120820003211714">Mac OSx Hints</a>.</p>
<p>I don&#8217;t like the iCloud UI for OSx &#8211; it&#8217;s inferior to Dropbox. As each  <em>application </em>has it&#8217;s own iCloud storage it&#8217;s pretty hard to store a heterogeneous set of documents relating to a project or customer. For example, a Contract document and an Expenses spreadsheet would be invisible from each other&#8217;s program &#8211; and Finder.</p>
<p>So, the hell with iCloud by default &#8211; let&#8217;s use the filesystem. In terminal, run:</p>
<pre>defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false</pre>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/jst-_mls-00" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/09/change-default-save-location-from-icloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/09/change-default-save-location-from-icloud/</feedburner:origLink></item>
		<item>
		<title>Slow Site Creation in SharePoint 2010</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/or0rxYue4pw/</link>
		<comments>http://www.novolocus.com/2012/10/05/slow-site-creation-in-sharepoint-2010/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 10:20:22 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Admin 2010]]></category>
		<category><![CDATA[STSADM]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2503</guid>
		<description><![CDATA[I have a development machine that I was creating a number of sites within. I wanted to create about 10,000 sites or so (and have done more than that in testing before without a problem). When I started the process that &#8230; <a href="http://www.novolocus.com/2012/10/05/slow-site-creation-in-sharepoint-2010/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have a development machine that I was creating a number of sites within. I wanted to create about 10,000 sites or so (and <a title="How many sub-sites can a site have?" href="http://www.novolocus.com/2011/05/11/how-many-sub-sites-can-a-site-have/">have done more than that in testing before</a> without a problem). When I started the process that was creating these running on my machine it was taking about 20 seconds per site. After a mere 2000 sites, it was then talking <strong>30 minutes </strong>per site. Something isn&#8217;t right.</p>
<p>I did a bit of digging and found that <a href="http://stackoverflow.com/questions/564670/creating-a-sub-site-in-sharepoint-takes-a-very-long-time">others have had the same problem</a> &#8211; but no solution.</p>
<p>I then spoke to one of our administrators, and he suggest clearing out the &#8216;event cache&#8217; table. I&#8217;d never heard of that (and I&#8217;ve no idea how he found out about it), but his advice was:</p>
<blockquote><p>Minimise the amount of rows in the EventCache SQL table:</p>
<ul>
<li>set ChangeLogRetentionPeriod to 1 day (1.00:00:00) on web application</li>
<li>set EventLogRetentionPeriod to 1 day (1.00:00:00) on web application</li>
<li>set &#8216;Change Log&#8217; timer job to run daily (default is weekly)</li>
</ul>
</blockquote>
<p>Okay, so I did this <a href="http://technet.microsoft.com/en-us/library/cc261921(v=office.12).aspx">using STSADM</a>:</p>
<p><code>stsadm -o setproperty -pn change-log-retention-period -pv 1<br />
stsadm -o setproperty -pn event-log-retention-period -pv 1</code></p>
<p>&#8230;and I then changed the Change Log timer job&#8217; schedule in central admin, and set it running right away.</p>
<p>The timer job took about 8 minutes to run. That was a surprisingly long time.</p>
<p>When I then tried creating a site, it took 7 minutes. Clearly, this is still an unwell system, but that&#8217;s a lot better than 30 minutes. I&#8217;ll update if I find more.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/or0rxYue4pw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/05/slow-site-creation-in-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/05/slow-site-creation-in-sharepoint-2010/</feedburner:origLink></item>
		<item>
		<title>Fixing Duplicate Icons in OSX Launchpad</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/Q7ViS2hmYnk/</link>
		<comments>http://www.novolocus.com/2012/10/05/fixing-duplicate-icons-in-osx-launchpad/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 09:54:13 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[OSx]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2499</guid>
		<description><![CDATA[I know, a little off-topic for a mostly SharePoint/.NET blog, but after a recent upgrade I found I had duplicate iPhoto icons in Launchpad. That frustrated me. I did a bit of Googling, and found others had the same problem, &#8230; <a href="http://www.novolocus.com/2012/10/05/fixing-duplicate-icons-in-osx-launchpad/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I know, a little off-topic for a mostly SharePoint/.NET blog, but after a recent upgrade I found I had duplicate iPhoto icons in Launchpad. That frustrated me. I did a bit of Googling, and found <a href="https://discussions.apple.com/thread/3191334?start=0&amp;tstart=0">others had the same problem</a>, and were suggesting<a href="https://discussions.apple.com/thread/3189437?start=0&amp;tstart=0"> deleting the database that stores the Launchpad&#8217;s details</a>. When the Dock was reloaded, it would recreate that database. Unfortunately, it would also lose the layout of <strong>all </strong>your folders and icons.</p>
<p>&#8220;Delete the database&#8221;, I thought, &#8220;It&#8217;s a database, how hard can it be to fix that?&#8221;</p>
<p>So I set out to fix the database without deleting it, and losing all my folders&#8230;<span id="more-2499"></span></p>
<p>The database that launchpad uses is a sqlite database, so I opened Terminal, and opened the database:</p>
<p><code>andy$ sqlite3 ~/Library/Application\ Support/Dock/*.db</code></p>
<p>This command tells the terminal to open a sqlite session, connecting to any database (and there only is one) inside the Library &gt; Application Support &gt; Dock folder.</p>
<p>Next, I wanted to query the &#8216;apps&#8217; table to find any called &#8216;iPhoto&#8217; (I&#8217;m skipping over how I found there was an apps table &#8211; but see<a href="http://jitsik.com/wordpress/?p=275"> this blog post</a> &#8211; and that it had a &#8216;title&#8217; column)</p>
<p><code>sqlite&gt; select * from apps where title="iPhoto";<br />
18|iPhoto|com.apple.iPhoto||8|370119271.0|bookx<br />
146|iPhoto|com.apple.iPhoto||8|370125850.0|book?</code></p>
<p>Hmm. Two rows returned. The | character separates the different columns, and the penultimate column &#8211; the long number &#8211; is the modified date. Therefore, I assumed that row ID 18 with the lower (earlier) modified date is actually the old icon. It was this one I wanted to delete. I ran a select to check I was only getting it, and then deleted it.</p>
<p><code>sqlite&gt; select * from apps where title="iPhoto" and item_id=18;<br />
18|iPhoto|com.apple.iPhoto||8|370119271.0|bookx</code></p>
<p><code>sqlite&gt; delete from apps where title="iPhoto" and item_id=18;</code></p>
<p>A quick check showed one remaining iPhoto entry:</p>
<p><code>sqlite&gt; select * from apps where title="iPhoto";<br />
146|iPhoto|com.apple.iPhoto||8|370125850.0|book?</code></p>
<p>Finally, I ran the command</p>
<p><code>killall Dock</code></p>
<p>This is a bit terrifying &#8211; it closes the process supporting the Dock &#8211; but like Explorer in Windows, this restarts automatically, and when it does it loads the newly modified database file &#8211; without the second iPhoto icon.</p>
<p>Problem solved, without having to reorganise all my icons.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/Q7ViS2hmYnk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/10/05/fixing-duplicate-icons-in-osx-launchpad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/10/05/fixing-duplicate-icons-in-osx-launchpad/</feedburner:origLink></item>
		<item>
		<title>Every Developer should know about Cryptography</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/PoXF43LHtVU/</link>
		<comments>http://www.novolocus.com/2012/08/16/every-developer-should-know-about-cryptography/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 15:00:39 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[crypto]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2490</guid>
		<description><![CDATA[It fascinates me, but it seems like a lot of developers don&#8217;t know a lot about cryptography. Certainly, the litany of security bloopers caused by incorrectly implemented crypto makes it appear that way. Encryption isn&#8217;t something that I work with &#8230; <a href="http://www.novolocus.com/2012/08/16/every-developer-should-know-about-cryptography/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>It fascinates me, but it seems like a lot of developers don&#8217;t know a lot about cryptography. Certainly, the litany of security bloopers caused by incorrectly implemented crypto makes it appear that way.</p>
<p>Encryption isn&#8217;t something that I work with every day, but as a web developer you can&#8217;t really get away from needing to secure something &#8211; and that means encryption.So, to overcome some of this it&#8217;s worth a bit of reading.</p>
<p>Bruce Schneier is a pretty interesting author. His books on <a href="http://www.amazon.co.uk/Applied-Cryptography-Protocols-Algorithms-Source/dp/0471117099/ref=sr_1_4">Applied Cryptography</a> and <a href="http://www.amazon.co.uk/Practical-Cryptography-Niels-Ferguson/dp/0471223573/ref=sr_1_7">Practical Cryptography</a> are excellent, and well worth a read for anyone starting to work with crypto. His <a href="http://www.schneier.com/">blog </a>is also an interesting discussion of security and risk in a wider context.</p>
<p><a href="http://www.troyhunt.com/">Troy Hunt </a>has managed to write a number of posts that have grabbed my attention over the year or so. &#8220;Lessons in web site security anti-patterns&#8221; is <a href="http://www.troyhunt.com/2012/07/lessons-in-website-security-anti.html">just that</a>, &#8220;A brief Sony password analysis&#8221; is <a href="http://www.troyhunt.com/2011/06/brief-sony-password-analysis.html">fascinating</a>, and &#8220;Our password hashing has no clothes&#8221; was eye <a href="http://www.troyhunt.com/2012/06/our-password-hashing-has-no-clothes.html">opening</a>. I like that his posts are strongly based on systematic analysis.</p>
<p><a href="http://crypto.stackexchange.com/">Cryptography on StackExchange </a>can be interesting. It&#8217;s where I first heard of <a href="http://en.wikipedia.org/wiki/Scrypt">scrypt</a>, which is quite interesting.</p>
<p>Anyway, I&#8217;ll try and update this if I find new, useful resources, or post your own favourites in the comments.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/PoXF43LHtVU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/08/16/every-developer-should-know-about-cryptography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/08/16/every-developer-should-know-about-cryptography/</feedburner:origLink></item>
		<item>
		<title>Deploy a solution to the sandbox in C#</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/imxM1oPylrg/</link>
		<comments>http://www.novolocus.com/2012/08/15/deploy-a-solution-to-the-sandbox-in-c/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 13:00:53 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[SPSolution]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2487</guid>
		<description><![CDATA[I came across a question on StackOverflow about how to programmatically deploy a sandbox solution, and this seemed a good question. Here&#8217;s what I came up with&#8230; Edit: Additional note &#8211; you can use this to copy Site Templates (as &#8230; <a href="http://www.novolocus.com/2012/08/15/deploy-a-solution-to-the-sandbox-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I came across a <a href="http://sharepoint.stackexchange.com/questions/42927/programmatically-deploy-to-site-collection-level-using-c/">question on StackOverflow</a> about how to programmatically deploy a sandbox solution, and this seemed a good question. Here&#8217;s what I came up with&#8230;</p>
<p><span id="more-2487"></span></p>
<pre class="brush: csharp; title: ; notranslate">SPSite site = ...
SPFile sourceSolutionFile = ...
//Get the Solution Gallery for the SPSite
SPDocumentLibrary solutionGallery = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.SolutionCatalog);
//Add the WSP File. I've used a source that is an SPFile, but really it's a string and byte array
SPFile solutionFile = solutionGallery.RootFolder.Files.Add(sourceSolutionFile.File.Name, sourceSolutionFile.File.OpenBinary());
// Activate Solution
SPUserSolution newUserSolution = newSite.Solutions.Add(solutionFile.Item.ID);</pre>
<p>Edit: Additional note &#8211; you can use this to copy Site Templates (as WSPs) from one Site Collection to another.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/imxM1oPylrg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/08/15/deploy-a-solution-to-the-sandbox-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/08/15/deploy-a-solution-to-the-sandbox-in-c/</feedburner:origLink></item>
		<item>
		<title>Strange issue with Application Page and Two Button Presses</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/L8P1cdNoiaA/</link>
		<comments>http://www.novolocus.com/2012/08/09/strange-issue-with-application-page-and-two-button-presses/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 15:29:46 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[Application Pages]]></category>
		<category><![CDATA[List Forms]]></category>
		<category><![CDATA[SmallSearchInputBox]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2480</guid>
		<description><![CDATA[Okay, this one was weird. The symptom is this &#8211; I had a custom Application page that was being used as the New and Edit forms for a particular custom list in my solution. One of the customisations was that &#8230; <a href="http://www.novolocus.com/2012/08/09/strange-issue-with-application-page-and-two-button-presses/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Okay, this one was weird. The symptom is this &#8211; I had a custom Application page that was being used as the New and Edit forms for a particular custom list in my solution. One of the customisations was that it had an &#8216;Address Search&#8217; button that, when you pressed, searched for an address based on the first line of the address, or the postcode.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/08/My-Form.png"><img class="aligncenter size-medium wp-image-2482" title="My Form" src="http://www.novolocus.com/wp-content/uploads/2012/08/My-Form-300x231.png" alt="" width="300" height="231" /></a></p>
<p>That&#8217;s fine, but here&#8217;s where things got weird.</p>
<ul>
<li>If you were using the form as a New form, then search worked just fine the first time you clicked it.</li>
<li>If you were using the form as an Edit form, the the search button didn&#8217;t work the first time you use it &#8211; but did the second time you clicked on it.</li>
</ul>
<p>Bizarre, and I had to fix it&#8230;<span id="more-2480"></span></p>
<p>I started looking at obvious things (i.e. my code) but that looked okay. I debugged the page lifecycle and found that my code wouldn&#8217;t break &#8211; heck, it didn&#8217;t even appear to be called &#8211; during the &#8220;first click in Edit more&#8221; scenario &#8211; but it did break on the second click. That&#8217;s pretty weird &#8211; clicking the same button should run the same code each time. I tried break pointing every function in my C# page-behind, and none of those breakpoints were hit. It was like the page wasn&#8217;t running at all, and yet I could see the form.</p>
<p>I began to think it was something fundamentally different about the page, so I decided to compare the source of my Edit form before and after that first click.</p>
<p>The first thing I noticed was that the files were different sizes. This seemed surprising, but I figured that things like the ViewState could account for that. So, next, I used WinMerge to highlight differences. There were 12 differences, mostly to do with transient data, such as the viewstate, and different digests. However, when I got to the  middle of the file I found a difference in the controls being added to the page.</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/08/Edit-form-Differences.png"><img class="aligncenter size-medium wp-image-2481" title="Edit form Differences" src="http://www.novolocus.com/wp-content/uploads/2012/08/Edit-form-Differences-300x163.png" alt="" width="300" height="163" /></a></p>
<p>This is the Small Search box, which caught me off-guard. It appeared to have an extra control on the page before the first &#8216;search&#8217; button click. Afterwards, it was gone.</p>
<p>By this point I was in a hurry, so I decided to try just removing the search box from the page. We don&#8217;t need it anyway. The search box is put in a ContentPlaceHolder control, so I decided to blank that out:</p>
<p><img class="aligncenter size-medium wp-image-2483" title="Blanking out the PlaceHolderSearchArea" src="http://www.novolocus.com/wp-content/uploads/2012/08/Blanking-out-the-PlaceHolderSearchArea-300x30.png" alt="" width="300" height="30" /></p>
<p>And mysteriously, my page and it&#8217;s search button started working again. I think that what&#8217;s happening is that the Search Box control loaded by the delegate is dynamically creating webcontrols. However, for some reason, on the postback it isn&#8217;t creating the same controls. This should cause an exception due to the invalid viewstate, but for some reason this wasn&#8217;t being shown. However, this exception would happen before any of my code was run &#8211; which is why none of my breakpoints would be hit on the first button press.</p>
<p>All in all, strange, but hopefully it might help someone else if they have the same problem.</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/L8P1cdNoiaA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/08/09/strange-issue-with-application-page-and-two-button-presses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/08/09/strange-issue-with-application-page-and-two-button-presses/</feedburner:origLink></item>
		<item>
		<title>CQWP and Discussions</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/e7qXcDet7QQ/</link>
		<comments>http://www.novolocus.com/2012/08/08/cqwp-and-discussions/#comments</comments>
		<pubDate>Wed, 08 Aug 2012 10:46:02 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[CQWP]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2469</guid>
		<description><![CDATA[Hmm. Interesting problem &#8211; I had a Content Query Web Part (CQWP) that was displaying the Title for Discussions. Unfortunately when you clicked on them, they took you to the display form for the start of the thread, not the entire &#8230; <a href="http://www.novolocus.com/2012/08/08/cqwp-and-discussions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Hmm. Interesting problem &#8211; I had a Content Query Web Part (CQWP) that was displaying the Title for Discussions. Unfortunately when you clicked on them, they took you to the display form for the start of the thread, not the entire thing:</p>
<p><a href="http://www.novolocus.com/wp-content/uploads/2012/08/DisplayForm.png"><img class="aligncenter size-medium wp-image-2470" title="DisplayForm" src="http://www.novolocus.com/wp-content/uploads/2012/08/DisplayForm-300x95.png" alt="" width="300" height="95" /></a></p>
<p>Okay, but could I get it to link to a view of the discussion thread itself?</p>
<p><span id="more-2469"></span></p>
<p>I tried using the <em>LinkUrl</em> property, but that didn&#8217;t work very well &#8211; when I tried to set it as the link in the CQWP it said that that field didn&#8217;t exist. It does though.</p>
<p>So I checked Google. It turns out that <a href="http://blogs.msdn.com/b/mutaz/archive/2009/06/06/customising-content-query-web-part-cqwp-and-discussion-boards.aspx">this has been written about before</a>. The short of it seems to be that the XSL styles that are emitting the link on the page call an XSL template OuterTemplate.GetSafeLink :</p>
<pre class="brush: xml; title: ; notranslate">&lt;xsl:variable name=&quot;myLink&quot;&gt;
&lt;xsl:call-template name=&quot;OuterTemplate.GetSafeLink&quot;&gt;
&lt;xsl:with-param name=&quot;UrlColumnName&quot; select=&quot;'LinkUrl'&quot;/&gt;
&lt;/xsl:call-template&gt;
&lt;/xsl:variable&gt;</pre>
<p>We don&#8217;t want the safe link &#8211; it takes us to the Display Form &#8211; but rather we just want the LinkUrl value itself:</p>
<pre class="brush: xml; title: ; notranslate">&lt;xsl:variable name=&quot;myLink&quot;&gt; 
&lt;xsl:value-of select=&quot;@LinkUrl&quot;/&gt; 
&lt;/xsl:variable&gt; </pre>
<p>That seems to work nicely. It&#8217;s a bit of a pain that you have to modify ItemStyles.xsl &#8211; and it&#8217;s a fair while since I last had to!</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/e7qXcDet7QQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/08/08/cqwp-and-discussions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/08/08/cqwp-and-discussions/</feedburner:origLink></item>
		<item>
		<title>Programmatically evaluate SPWebApplication Policies</title>
		<link>http://feedproxy.google.com/~r/novolocus/~3/MRP2pr3HlPA/</link>
		<comments>http://www.novolocus.com/2012/08/03/programmatically-evaluate-spwebapplication-policies/#comments</comments>
		<pubDate>Fri, 03 Aug 2012 09:29:34 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Development 2010]]></category>
		<category><![CDATA[SPWebApplication]]></category>

		<guid isPermaLink="false">http://www.novolocus.com/?p=2462</guid>
		<description><![CDATA[An interesting question came up on StackOverflow &#8211; how do you get the web application level policies for a Web app? In other words, the rights that you can grant to an entire web application (via central administration) &#8211; how &#8230; <a href="http://www.novolocus.com/2012/08/03/programmatically-evaluate-spwebapplication-policies/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>An interesting question came up on StackOverflow &#8211; how do you get the web application level policies for a Web app? In other words, the rights that you can grant to an entire web application (via central administration) &#8211; how do you get those in code?</p>
<p><span id="more-2462"></span></p>
<p>It turns out that this is done via the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.sppolicycollection">SPWebApplication.Policies </a>collection, which is actually pretty simple to use:</p>
<pre class="brush: csharp; title: ; notranslate">System.Uri uri = new Uri(&quot;http://sp/&quot;);
SPWebApplication webApplication = SPWebApplication.Lookup(uri)
SPPolicyCollection policyCollection = webApplication.Policies;
SPPolicyRoleCollection policyRoles = webApplication.PolicyRoles;
foreach (SPPolicy p in policyCollection)
{
    Console.WriteLine(&quot;{0} - {1}&quot;, p.DisplayName, p.UserName);                 
    foreach (SPPolicyRole pr in p.PolicyRoleBindings)                 
    {                     
        Console.WriteLine(&quot;     {0} - IsAdmin: {1}, FullControl: {2}&quot;, pr.Name, 
                pr.IsSiteAdmin, pr.GrantRightsMask == SPBasePermissions.FullMask);                 
    }             
}</pre>
<p>Might be useful someday.</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/novolocus/~4/MRP2pr3HlPA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.novolocus.com/2012/08/03/programmatically-evaluate-spwebapplication-policies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.novolocus.com/2012/08/03/programmatically-evaluate-spwebapplication-policies/</feedburner:origLink></item>
	</channel>
</rss>
