<?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>Black Ninja Software &#187; sharepoint</title>
	<atom:link href="http://blackninjasoftware.com/tag/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://blackninjasoftware.com</link>
	<description>SharePoint and SQL Server Consulting, Business Intelligence and Reporting, ASP.NET Vancouver</description>
	<lastBuildDate>Fri, 07 Oct 2011 00:15:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Programmatically and Selectively Revoke SharePoint Item-Level Permissions Using PowerShell</title>
		<link>http://blackninjasoftware.com/2010/06/20/programmatically-and-selectively-revoke-sharepoint-item-level-permissions-using-powershell/</link>
		<comments>http://blackninjasoftware.com/2010/06/20/programmatically-and-selectively-revoke-sharepoint-item-level-permissions-using-powershell/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 09:36:09 +0000</pubDate>
		<dc:creator>donabel</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://blackninjasoftware.com/?p=1095</guid>
		<description><![CDATA[I&#8217;ve been using PowerShell more and more lately, and liking it more and more as I use it. Here&#8217;s another one you might find useful &#8211; programmatically and selectively revoking item-level permissions. For this scenario, the SharePoint list already has inheritance broken. Now we have to loop through the versions of SharePoint list items, and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using PowerShell more and more lately, and liking it more and more as I use it. </p>
<p>Here&#8217;s another one you might find useful &#8211; programmatically and selectively revoking item-level permissions. For this scenario, the SharePoint list already has inheritance broken. Now we have to loop through the versions of SharePoint list items, and check a people/group column called Participant. A participant would have had read/contribute permissions before, but after the list item has been verified, we don&#8217;t want the participants changing any of the values anymore.</p>
<p>We will start with the typical loading of the DLL, and creating a handle to our SharePoint site:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#Load the SharePoint DLL</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadWithPartialName</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SharePoint&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #800080;">$SiteURL</span> <span style="color: pink;">=</span> <span style="color: #800080;">$server</span>;
&nbsp;
<span style="color: #008000;">#make sure we're using the system account token</span>
<span style="color: #800080;">$TmpSite</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Microsoft.SharePoint.SPSite<span style="color: #000000;">&#40;</span><span style="color: #800080;">$SiteURL</span><span style="color: #000000;">&#41;</span>;
<span style="color: #800080;">$SysToken</span> <span style="color: pink;">=</span> <span style="color: #800080;">$TmpSite</span>.SystemAccount.UserToken;
&nbsp;
<span style="color: #800080;">$SPSite</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Microsoft.SharePoint.SPSite<span style="color: #000000;">&#40;</span><span style="color: #800080;">$SiteURL</span><span style="color: pink;">,</span><span style="color: #800080;">$SysToken</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008000;">#if we want to get additional info about SPSite, code is below</span>
<span style="color: #008000;">#$SPSite.AllWebs | Format-Table Url, ID, Name, AllUsers</span>
&nbsp;
<span style="color: #800080;">$SPWeb</span> <span style="color: pink;">=</span> <span style="color: #800080;">$SPSite</span>.OpenWeb<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #800080;">$SPWeb</span>.AllowUnsafeUpdates <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>;
&nbsp;
<span style="color: #800080;">$MyList</span> <span style="color: pink;">=</span> <span style="color: #800080;">$SPWeb</span>.Lists<span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;My Sample List&quot;</span><span style="color: #000000;">&#93;</span>;</pre></td></tr></table></div>

<p>Now let&#8217;s get only verified items from our list:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">#note your ending herestring must NOT have a space before it.</span>
<span style="color: #008000;">#also, this &quot;Project Audited&quot; field is really a boolean, </span>
<span style="color: #008000;">#but using the Integer works</span>
<span style="color: #800080;">$CAML</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #800000;">&quot;
&lt;Where&gt;
     &lt;Eq&gt;
        &lt;FieldRef Name='Project_x0020_Verified' /&gt;
        &lt;Value Type='Integer'&gt;1&lt;/Value&gt;
     &lt;/Eq&gt;
  &lt;/Where&gt;
&quot;</span><span style="color: pink;">@</span>
&nbsp;
<span style="color: #800080;">$SPQuery</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Microsoft.SharePoint.SPQuery;
<span style="color: #800080;">$SPQuery</span>.Query <span style="color: pink;">=</span> <span style="color: #800080;">$CAML</span>;
&nbsp;
<span style="color: #800080;">$itemCollection</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>;
<span style="color: #800080;">$itemCollection</span> <span style="color: pink;">=</span> <span style="color: #800080;">$MyList</span>.GetItems<span style="color: #000000;">&#40;</span><span style="color: #800080;">$SPQuery</span><span style="color: #000000;">&#41;</span>;
<span style="color: #800080;">$listItem</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>;</pre></td></tr></table></div>

<p>Now the bulk of the work is as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ItemCollection</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$listItem</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$itemCollection</span><span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #800080;">$ID</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$listItem</span><span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;ID&quot;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #800080;">$ProjectVerified</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$listItem</span><span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;Project Verified&quot;</span><span style="color: #000000;">&#93;</span>
&nbsp;
        <span style="color: #008000;">#now I want to display the roles before I revoke, </span>
        <span style="color: #008000;">#so I can verify the changes visually</span>
        <span style="color: #008000;">#assume in here you already created a new file for </span>
        <span style="color: #008000;">#this process, and gave it a handle $logfile</span>
        <span style="color: #800000;">&quot;Roles BEFORE revoke : &quot;</span>  <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800080;">$logfile</span> <span style="color: #008080; font-style: italic;">-Append</span>
        <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$role</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$roles</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$msg</span> <span style="color: pink;">=</span>  <span style="color: #800000;">&quot;Role : ID &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$role</span>.Member.ID.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; : Name  &quot;</span> <span style="color: pink;">+</span>  <span style="color: #800080;">$role</span>.Member.Name
            <span style="color: #800080;">$msg</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800080;">$logfile</span> <span style="color: #008080; font-style: italic;">-Append</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">#get the item versions (SPListItemVersionCollection)</span>
        <span style="color: #800080;">$itemVersionCollection</span> <span style="color: pink;">=</span> <span style="color: #800080;">$listItem</span>.Versions;
&nbsp;
        <span style="color: #008000;">#need to check current permissions</span>
        <span style="color: #008000;">#we'll store all Participants in an array first and evaluate later</span>
        <span style="color: #800080;">$Participants</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        <span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$currentVersion</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$itemVersionCollection</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$SPFieldUserValue</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Microsoft.SharePoint.SPFieldUserValue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$SPWeb</span><span style="color: pink;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$currentVersion</span><span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;Participant&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #800080;">$Participants</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$SPFieldUserValue</span>.User.LoginName
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">#now, we just want to get the unique people from the version, </span>
        <span style="color: #008000;">#so we don't unnecessarily revoke</span>
        <span style="color: #800080;">$Participants</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Participants</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">SELECT</span> <span style="color: #008080; font-style: italic;">-Unique</span>
&nbsp;
        <span style="color: #008000;">#let's now revoke permissions for every participant</span>
        <span style="color: #008000;">#that has ever been involved in any version of this item</span>
        <span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Participant</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Participants</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$user</span> <span style="color: pink;">=</span> <span style="color: #800080;">$SPWeb</span>.AllUsers<span style="color: #000000;">&#91;</span><span style="color: #800080;">$Participant</span><span style="color: #000000;">&#93;</span>;
            <span style="color: #800080;">$listItem</span>.RoleAssignments.Remove<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>Microsoft.SharePoint.SPUser<span style="color: #000000;">&#93;</span><span style="color: #800080;">$user</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">#confirm</span>
        <span style="color: #800000;">&quot;Roles AFTER revoke : &quot;</span>  <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800080;">$logfile</span> <span style="color: #008080; font-style: italic;">-Append</span>
        <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$role</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$roles</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$msg</span> <span style="color: pink;">=</span>  <span style="color: #800000;">&quot;Role : ID &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$role</span>.Member.ID.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; : Name  &quot;</span> <span style="color: pink;">+</span>  <span style="color: #800080;">$role</span>.Member.Name
            <span style="color: #800080;">$msg</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800080;">$logfile</span> <span style="color: #008080; font-style: italic;">-Append</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span> 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And <strong>very very important</strong>, do not forget to <strong>dispose</strong> the SPWeb and SPSite objects you created. It&#8217;s VERY bad to not dispose it, as it will definitely slow down your site, one way or another. Believe me, you don&#8217;t want to learn this the hard way.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$SPWeb</span>.Dispose<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #800080;">$SPSite</span>.Dispose<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #800080;">$TmpSite</span>.Dispose<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<p>Done. Happy times.</p>
<p>-<a href="http://www.sqlmusings.com" target="_blank"> Donabel (@sqlbelle)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blackninjasoftware.com/2010/06/20/programmatically-and-selectively-revoke-sharepoint-item-level-permissions-using-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>We&#8217;ve Added an Aztec Warrior to Our Team!</title>
		<link>http://blackninjasoftware.com/2010/03/23/weve-added-an-aztec-warrior-to-our-team/</link>
		<comments>http://blackninjasoftware.com/2010/03/23/weve-added-an-aztec-warrior-to-our-team/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 20:02:33 +0000</pubDate>
		<dc:creator>donabel</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://blackninjasoftware.com/?p=1010</guid>
		<description><![CDATA[We&#8217;re very excited to welcome Miguel A. Tena as the newest member of the Black Ninja team! As you&#8217;ll read more about in his bio, Miguel is a huge fan of SharePoint and ASP.NET development and is already gearing up to become super active in the SharePoint and .NET communities. He&#8217;s been working with SharePoint [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re very excited to welcome <strong>Miguel A. Tena</strong> as the newest member of the Black Ninja team! As you&#8217;ll read more about in his <a href="http://blackninjasoftware.com/about">bio</a>, Miguel is a huge fan of SharePoint and ASP.NET development and is already gearing up to become super active in the SharePoint and .NET communities. He&#8217;s been working with SharePoint since it&#8217;s early days and we&#8217;ve already begun leveraging his knowledge, enthusiasm and passion for further development of our training services. Stay tuned for more updates from Miguel in the next couple of weeks.</p>
<p>So, please join us in welcoming Miguel, the Aztec Warrior, to our team!</p>
]]></content:encoded>
			<wfw:commentRss>http://blackninjasoftware.com/2010/03/23/weve-added-an-aztec-warrior-to-our-team/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Clear and Repopulate Your ASP.NET DropDown List with jQuery</title>
		<link>http://blackninjasoftware.com/2009/06/04/how-to-clear-and-repopulate-your-aspnet-dropdown-list-with-jquery/</link>
		<comments>http://blackninjasoftware.com/2009/06/04/how-to-clear-and-repopulate-your-aspnet-dropdown-list-with-jquery/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 04:41:28 +0000</pubDate>
		<dc:creator>donabel</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://blackninjasoftware.com/?p=654</guid>
		<description><![CDATA[Yes you can call and use your ASP.NET controls from jQuery! Shereen has already posted a blog on how you can access these controls JQuery Accessing the Client Generated ID of ASP.NET Controls so feel free to check it out there first. Recently we&#8217;ve had to create a UI that has a datepicker, and the date [...]]]></description>
			<content:encoded><![CDATA[<p>Yes you can call and use your ASP.NET controls from jQuery! Shereen has already posted a blog on how you can access these controls <a title="JQuery Accessing the Client Generated ID of ASP.NET Controls" href="http://blog.qumsieh.ca/2009/03/26/jquery-accessing-the-client-generated-id-of-aspnet-controls/">JQuery Accessing the Client Generated ID of ASP.NET Controls</a> so feel free to check it out there first.</p>
<p>Recently we&#8217;ve had to create a UI that has a datepicker, and the date that a user selects should determine what values get populated in an ASP.NET dropdown.</p>
<h3>Here&#8217;s how we did it</h3>
<p>We&#8217;ve listed below the two controls we&#8217;re using in this example: a calendar control and an asp.net drop down list.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;</span>input id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;datepicker&quot;</span> type<span style="color: #008000;">=</span><span style="color: #666666;">&quot;text&quot;</span> <span style="color: #008000;">/&gt;</span>
<span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>DropDownList ID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;ddlDates&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> Width<span style="color: #008000;">=</span><span style="color: #666666;">&quot;100px&quot;</span><span style="color: #008000;">&gt;&lt;/</span>asp<span style="color: #008000;">:</span>DropDownList<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p>For the date picker, we used the <a href="http://jqueryui.com/demos/datepicker/">DatePicker control from jQueryUI</a>. Their demos and documentation are a great starting point, if you have any troubles with the calendar on your site, drop us a line.</p>
<p>Next, we had to add the following references:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;http://myserver/js/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://myserver/js/jquery-ui-1.7.1.custom.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>Then we wired it up! Good ol&#8217; jQuery!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> PopulateDropDownDates<span style="color: #009900;">&#40;</span>dateText<span style="color: #339933;">,</span> numDaysToAdd<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> selectedDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>dateText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//clear the dropdown</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&lt;%= ddlDates.ClientID %&gt;&gt;option&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//add todays date</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&lt;%= ddlDates.ClientID %&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;option&gt;&lt;/option&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>dateText<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>dateText<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//counter</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> numDaysToAdd<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> currentDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>selectedDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> selectedDate.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> selectedDate.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        currentDate <span style="color: #339933;">=</span> currentDate.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;/&quot;</span> <span style="color: #339933;">+</span> currentDate.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;/&quot;</span> <span style="color: #339933;">+</span> currentDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&lt;%= ddlDates.ClientID %&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;option&gt;&lt;/option&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>currentDate<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>currentDate<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
            onSelect<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>dateText<span style="color: #339933;">,</span> inst<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                PopulateDropDownDates<span style="color: #009900;">&#40;</span>dateText<span style="color: #339933;">,</span> <span style="color: #CC0000;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Voila! That&#8217;s it. Works beautifully!</p>
]]></content:encoded>
			<wfw:commentRss>http://blackninjasoftware.com/2009/06/04/how-to-clear-and-repopulate-your-aspnet-dropdown-list-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Should Indexing a SharePoint Field Break Your CAML Query?</title>
		<link>http://blackninjasoftware.com/2009/05/12/why-should-indexing-a-sharepoint-field-break-your-caml-query/</link>
		<comments>http://blackninjasoftware.com/2009/05/12/why-should-indexing-a-sharepoint-field-break-your-caml-query/#comments</comments>
		<pubDate>Tue, 12 May 2009 19:03:06 +0000</pubDate>
		<dc:creator>donabel</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://blackninjasoftware.com/?p=601</guid>
		<description><![CDATA[We ran into an issue today &#8211; one of our calculations that rely heavily on CAML queries stopped working. The CAML query we use &#8211; which we haven&#8217;t changed in forever and which used to work &#8211; now returns 0 results when run. This is what our original query looked like: 1 2 3 4 [...]]]></description>
			<content:encoded><![CDATA[<p>We ran into an issue today &#8211; one of our calculations that rely heavily on CAML queries stopped working. The CAML query we use &#8211; which we haven&#8217;t changed in forever and which used to work &#8211; now returns 0 results when run.</p>
<p>This is what our original query looked like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Eq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">'Project'</span> <span style="color: #000066;">LookupId</span>=<span style="color: #ff0000;">'TRUE'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Value</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">'Lookup'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>100<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/Eq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>It&#8217;s not a complicated query, and this used to work. Used to. But for some reason, it doesn&#8217;t anymore. </p>
<p>And for some reason, if we change the Value from Type=&#8217;Lookup&#8217; to Type=&#8217;Integer&#8217; it magically works again:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Eq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">'Project'</span> <span style="color: #000066;">LookupId</span>=<span style="color: #ff0000;">'TRUE'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Value</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">'Integer'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>100<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/Eq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Why will using Type=&#8217;Lookup&#8217; suddenly fail, and using Type=&#8217;Integer&#8217; work? Does this mean we need to change all of our CAML queries that use Lookup?</p>
<p>What changed? No new service packs. No recent patches. </p>
<p>We tried to retrace our steps, in the hope that we don&#8217;t have to rewrite all of our CAML queries and retest all our application pages:<br />
1.	No change<br />
2.	No change<br />
3.	Ah, one minor change, but all we did was <strong>create an index</strong> in the Project field because we have over 2000 items in this list.</p>
<p>Indexing the column should help optimize retrieving records from this list. But could indexing the Project field be the culprit? This seems to be about the only change we did on this list.</p>
<p>But I think to myself, it should not be the culprit. Right?</p>
<p>I am a database person, and I create indexes here, there and everywhere whenever I need performance gains on some of my reports (ok, let me qualify that, I index where it makes sense. Of course if it is a purely reporting read only database, then I will index the heck out of it. OLTP databases are a different story). So for me, I don&#8217;t think it should affect the way we retrieve our records using our CAML query.</p>
<p>We needed to test if this was the case, so we did a quick experiment:<br />
1.	Created a custom list with a field that uses a regular lookup to another list<br />
2.	Used CAML with Type=Lookup <span style="background-color:yellow">&#8212;&#8212;-&gt; Works</span><br />
3.	Indexed the column<br />
4.	Re-tried the CAML with Type=Lookup <span style="background-color:yellow">&#8212;&#8212;-&gt; Does not work</span><br />
5.	Tried CAML with Type=Integer <span style="background-color:yellow">&#8212;&#8212;-&gt; Works</span><br />
6.	Removed index from column<br />
7.	Re-tried the CAML with Type=Lookup <span style="background-color:yellow">&#8212;&#8212;-&gt; Magically works again</span></p>
<p>So, why would (or should) the implementation of our CAML query change when we decide to index, or drop an index, from one of our SharePoint lists?</p>
<p>We tried to look for an explanation, but we haven&#8217;t found any official documentation, or any definitive rationale.<br />
<strong style="color:red"><br />
Again, maybe I just don&#8217;t understand, but in my database world, creating indexes, or dropping indexes from my tables does not break my SQL queries.</p>
<p>So why should indexing break a query in the SharePoint world?<br />
</strong></p>
<p>Anyone from Microsoft SharePoint team care to explain? I&#8217;m sure we&#8217;re not the only ones interested to know the answer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blackninjasoftware.com/2009/05/12/why-should-indexing-a-sharepoint-field-break-your-caml-query/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

