<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Technical Fun</title>
	<atom:link href="http://asadewa.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://asadewa.wordpress.com</link>
	<description>Asfar Sadewa's trivias, eurekas, and mamamias on MOSS, CRM, and regular .Net</description>
	<lastBuildDate>Tue, 14 Oct 2008 00:56:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='asadewa.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Technical Fun</title>
		<link>http://asadewa.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://asadewa.wordpress.com/osd.xml" title="Technical Fun" />
	<atom:link rel='hub' href='http://asadewa.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Fun with Wordle</title>
		<link>http://asadewa.wordpress.com/2008/10/14/fun-with-wordle/</link>
		<comments>http://asadewa.wordpress.com/2008/10/14/fun-with-wordle/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 00:54:29 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[Rambling]]></category>
		<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/10/14/fun-with-wordle/</guid>
		<description><![CDATA[Eh, Ok, It’s been a while since I last put any entry here. But for now, I don’t want to write any technical thing, instead I am gonna show you something Fun. Have you checked wordle? If not, you should. Take a look at one sample result I created out of this blog’s URL. Technical [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=26&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Eh, Ok, It’s been a while since I last put any entry here.<br />
But for now, I don’t want to write any technical thing, instead I am gonna show you something Fun.</p>
<p>Have you checked <a href="http://wordle.net">wordle</a>?</p>
<p>If not, you should.</p>
<p>Take a look at one sample result I created out of this blog’s URL.</p>
<p><a href="http://wordle.net/gallery/wrdl/246648/Technical_Fun_-_Wordle">Technical Fun’s wordle</a></p>
<p><img src="http://wordle.net/thumb/wrdl/246648/Technical_Fun_-_Wordle" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=26&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/10/14/fun-with-wordle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>

		<media:content url="http://wordle.net/thumb/wrdl/246648/Technical_Fun_-_Wordle" medium="image" />
	</item>
		<item>
		<title>CRM 4.0: Fetching Picklist Content, and Pass It to the World!</title>
		<link>http://asadewa.wordpress.com/2008/06/12/crm-40-fetching-picklist-content-and-pass-it-to-the-world/</link>
		<comments>http://asadewa.wordpress.com/2008/06/12/crm-40-fetching-picklist-content-and-pass-it-to-the-world/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 04:30:26 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[CRM]]></category>
		<category><![CDATA[Rambling]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/06/12/crm-40-fetching-picklist-content-and-pass-it-to-the-world/</guid>
		<description><![CDATA[Holla holla, CRM Party dudes, it&#8217;s me again in a very mundane snippet series of CRM 4.0. This time, we&#8217;re gonna grab the content from a picklist attribute and show it to the world! (Well, usually they end up only seeing an asp.net web app, but whatever ..) Beware, this one&#8217;s an overkill scenario, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=20&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Holla holla, CRM Party dudes, it&#8217;s me again in a very mundane snippet series of CRM 4.0.<br />
This time, we&#8217;re gonna grab the content from a picklist attribute and show it to the world! (Well, usually they end up only seeing an asp.net web app, but whatever ..)</p>
<p>Beware, this one&#8217;s an overkill scenario, the essence is somewhere within. Seek. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First things first, I like to create an interface that should build the structure of a picklist object (Why? because .. just because).</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ba192252-5e5a-4413-a2a8-a562a23fd1ad" class="wlWriterSmartContent" style="display:inline;float:none;width:247px;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;">1</span> <span style="color:#0000ff;">interface</span><span style="color:#000000;"> IPicklistObject
</span><span style="color:#008080;">2</span> <span style="color:#000000;">{
</span><span style="color:#008080;">3</span> <span style="color:#000000;">    </span><span style="color:#0000ff;">int</span><span style="color:#000000;"> Id {</span><span style="color:#0000ff;">get</span><span style="color:#000000;">; </span><span style="color:#0000ff;">set</span><span style="color:#000000;">;}
</span><span style="color:#008080;">4</span> <span style="color:#000000;">    </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> Name {</span><span style="color:#0000ff;">get</span><span style="color:#000000;">; </span><span style="color:#0000ff;">set</span><span style="color:#000000;">;}
</span><span style="color:#008080;">5</span> <span style="color:#000000;">}</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Then, if an entity got many picklist attributes, we&#8217;ll create each class that implement that interface, just like that. (i.e: This SeverityLevel class below).</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:462eadc3-9213-4908-99b0-2c94c881c8b5" class="wlWriterSmartContent" style="display:inline;float:none;width:246px;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;"> 1</span> <span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">class</span><span style="color:#000000;"> SeverityLevel : IPicklistObject
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;">    {
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;">        </span><span style="color:#0000ff;">#region</span><span style="color:#000000;"> IPicklistObject Members</span><span style="color:#000000;">
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">int</span><span style="color:#000000;"> Id
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">        {
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">get</span><span style="color:#000000;">;
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">set</span><span style="color:#000000;">;
</span><span style="color:#008080;">10</span> <span style="color:#000000;">        }
</span><span style="color:#008080;">11</span> <span style="color:#000000;">
</span><span style="color:#008080;">12</span> <span style="color:#000000;">        </span><span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> Title
</span><span style="color:#008080;">13</span> <span style="color:#000000;">        {
</span><span style="color:#008080;">14</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">get</span><span style="color:#000000;">;
</span><span style="color:#008080;">15</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">set</span><span style="color:#000000;">;
</span><span style="color:#008080;">16</span> <span style="color:#000000;">        }
</span><span style="color:#008080;">17</span> <span style="color:#000000;">
</span><span style="color:#008080;">18</span> <span style="color:#000000;">        </span><span style="color:#0000ff;">#endregion</span><span style="color:#000000;">
</span><span style="color:#008080;">19</span> <span style="color:#000000;">    }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Further more, if you have many picklist-type attributes on your entity, you might want to do mapping externally. My method of choice was a custom xml file that holds to map, like this:<br />
(We&#8217;ll need this to pass to the Activator later ..[why??? sshhh ....!])</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c97f737e-88ca-4293-8712-7719555ba600" class="wlWriterSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;">1</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">2</span> <span style="color:#000000;"> </span><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">settings</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">3</span> <span style="color:#000000;">  </span><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">attributeName</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">4</span> <span style="color:#000000;">    </span><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">severitylevel</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">Full.Name.Of.Your.Concrete.Class.SeverityLevel</span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">severitylevel</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">5</span> <span style="color:#000000;">  </span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">attributeName</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">6</span> <span style="color:#000000;"> </span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">settings</span><span style="color:#0000ff;">&gt;</span><span style="color:#000000;">
</span><span style="color:#008080;">7</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>&lt;severitylevel&gt; tag is actually the name of the picklist attribute in crm.<br />
Well of course as a bonus snippet, here&#8217;s what I do to read this XML;</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:7eaa6022-f1b0-4b17-b81d-771e5c212f63" class="wlWriterSmartContent" style="display:inline;float:none;width:569px;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;"> 1</span> <span style="color:#0000ff;">private</span><span style="color:#000000;"> </span><span style="color:#0000ff;">static</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> getMappedValueOf(</span><span style="color:#0000ff;">string</span><span style="color:#000000;"> attributename)
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;">        {
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">            XmlDocument xDoc </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> XmlDocument();
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> sFileName </span><span style="color:#000000;">=</span><span style="color:#000000;"> YOUR_XML_FILE_LOCATION;
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (File.Exists(sFileName) </span><span style="color:#000000;">==</span><span style="color:#000000;"> </span><span style="color:#0000ff;">false</span><span style="color:#000000;">)
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">            {
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;">.Empty;
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">10</span> <span style="color:#000000;">
</span><span style="color:#008080;">11</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">try</span><span style="color:#000000;">
</span><span style="color:#008080;">12</span> <span style="color:#000000;">            {
</span><span style="color:#008080;">13</span> <span style="color:#000000;">                xDoc.Load(sFileName);
</span><span style="color:#008080;">14</span> <span style="color:#000000;">                XmlNode theNode </span><span style="color:#000000;">=</span><span style="color:#000000;"> xDoc.SelectSingleNode(</span><span style="color:#800000;">"</span><span style="color:#800000;">/configuration/settings/attributeName/</span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">+</span><span style="color:#000000;"> attributename);
</span><span style="color:#008080;">15</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (theNode </span><span style="color:#000000;">!=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">null</span><span style="color:#000000;">)
</span><span style="color:#008080;">16</span> <span style="color:#000000;">                    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> theNode.InnerText;
</span><span style="color:#008080;">17</span> <span style="color:#000000;">
</span><span style="color:#008080;">18</span> <span style="color:#000000;">                xDoc </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">null</span><span style="color:#000000;">;
</span><span style="color:#008080;">19</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;">.Empty;
</span><span style="color:#008080;">20</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">21</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">catch</span><span style="color:#000000;">
</span><span style="color:#008080;">22</span> <span style="color:#000000;">            {
</span><span style="color:#008080;">23</span> <span style="color:#000000;">                xDoc </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">null</span><span style="color:#000000;">;
</span><span style="color:#008080;">24</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">25</span> <span style="color:#000000;">
</span><span style="color:#008080;">26</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;">.Empty;
</span><span style="color:#008080;">27</span> <span style="color:#000000;">        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Ok, if you are somewhat still following this guide [ I really have no idea why you do that ], you will need to create this method;</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:bf1da557-f99a-4bb3-bceb-4edc89f3fe8e" class="wlWriterSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;"> 1</span> <span style="color:#0000ff;">private</span><span style="color:#000000;"> </span><span style="color:#0000ff;">static</span><span style="color:#000000;"> IPicklistObject CreateFrom(</span><span style="color:#0000ff;">string</span><span style="color:#000000;"> attributename, </span><span style="color:#0000ff;">int</span><span style="color:#000000;"> key, </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> name)
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;">        {
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">            Type atttype </span><span style="color:#000000;">=</span><span style="color:#000000;"> Type.GetType(getMappedValueOf(attributename.ToLower()), </span><span style="color:#0000ff;">false</span><span style="color:#000000;">);
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;">            IPicklistObject result </span><span style="color:#000000;">=</span><span style="color:#000000;"> (IPicklistObject)Activator.CreateInstance(atttype);
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">            result.Id </span><span style="color:#000000;">=</span><span style="color:#000000;"> key;
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">            result.Title </span><span style="color:#000000;">=</span><span style="color:#000000;"> name;
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> result;
</span><span style="color:#008080;">10</span> <span style="color:#000000;">        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Last and final thing, a method that will fetch the picklist attribute using the metadata service (if you&#8217;re not like me, this should be the only part you read).</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ed995b2d-be25-4c21-a161-9d0a075bfcc6" class="wlWriterSmartContent" style="display:inline;float:none;width:601px;margin:0;padding:0;">
<pre style="background-color:#80FF80;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;"> 1</span> <span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">static</span><span style="color:#000000;"> IList</span><span style="color:#000000;">&lt;</span><span style="color:#000000;">IPicklistObject</span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> getPickListValue(</span><span style="color:#0000ff;">string</span><span style="color:#000000;"> entityName, </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> pickListAttributeName)
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;">        {
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">            RetrieveAttributeRequest attributeRequest </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> RetrieveAttributeRequest();
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;">            attributeRequest.EntityLogicalName </span><span style="color:#000000;">=</span><span style="color:#000000;"> entityName;
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;">            attributeRequest.LogicalName </span><span style="color:#000000;">=</span><span style="color:#000000;"> pickListAttributeName;
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">            attributeRequest.RetrieveAsIfPublished </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">true</span><span style="color:#000000;">;
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">            RetrieveAttributeResponse attributeResponse </span><span style="color:#000000;">=</span><span style="color:#000000;">
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">                    (RetrieveAttributeResponse)metaService.Execute(attributeRequest);
</span><span style="color:#008080;">10</span> <span style="color:#000000;">
</span><span style="color:#008080;">11</span> <span style="color:#000000;">            PicklistAttributeMetadata pl </span><span style="color:#000000;">=</span><span style="color:#000000;">
</span><span style="color:#008080;">12</span> <span style="color:#000000;">                    (PicklistAttributeMetadata)attributeResponse.AttributeMetadata;
</span><span style="color:#008080;">13</span> <span style="color:#000000;">
</span><span style="color:#008080;">14</span> <span style="color:#000000;">            IList</span><span style="color:#000000;">&lt;</span><span style="color:#000000;">IPicklistObject</span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> resultset </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> List</span><span style="color:#000000;">&lt;</span><span style="color:#000000;">IPicklistObject</span><span style="color:#000000;">&gt;</span><span style="color:#000000;">();
</span><span style="color:#008080;">15</span> <span style="color:#000000;">
</span><span style="color:#008080;">16</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">foreach</span><span style="color:#000000;"> (Option o </span><span style="color:#0000ff;">in</span><span style="color:#000000;"> pl.Options)
</span><span style="color:#008080;">17</span> <span style="color:#000000;">            {
</span><span style="color:#008080;">18</span> <span style="color:#000000;">                resultset.Add(CreateFrom(pickListAttributeName,o.Value.Value,o.Label.UserLocLabel.ToString()));
</span><span style="color:#008080;">19</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">20</span> <span style="color:#000000;">
</span><span style="color:#008080;">21</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> resultset;
</span><span style="color:#008080;">22</span> <span style="color:#000000;">        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>So at this point, you can just pass this collection of picklist object to a control, (a drop down list in my case), and be happy.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=20&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/06/12/crm-40-fetching-picklist-content-and-pass-it-to-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>CRM 4.0: Adding Attachment / Notes Programmatically to Entities</title>
		<link>http://asadewa.wordpress.com/2008/06/10/crm-40-adding-attachment-notes-programmatically-to-entities/</link>
		<comments>http://asadewa.wordpress.com/2008/06/10/crm-40-adding-attachment-notes-programmatically-to-entities/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 00:48:48 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[CRM]]></category>
		<category><![CDATA[Rambling]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/06/10/crm-40-adding-attachment-notes-programmatically-to-entities/</guid>
		<description><![CDATA[Holla, CRM Party people, to entertain your greed towards CRM snippets and to keep me from forgetting such a trivial thing, here we go &#8230; the adding attachment / note / annotation snippet for CRM 4.0. (In this sample I am binding it to the incident entity). 1 public static bool AddAttachment(string filename, Guid incidentguid, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=19&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Holla, CRM Party people, to entertain your greed towards CRM snippets and to keep me from forgetting such a trivial thing, here we go &#8230; the adding attachment / note / annotation snippet for CRM 4.0. (In this sample I am binding it to the <em>incident</em> entity).</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c5f57387-a5b0-4f37-aa93-574ae8751bb2" class="wlWriterSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#BCDFA2;overflow:auto;font-family:Microsoft Sans Serif;font-size:11.25px;">
<div><span style="color:#008080;"> 1</span> <span style="color:#0000ff;">public</span><span style="color:#000000;"> </span><span style="color:#0000ff;">static</span><span style="color:#000000;"> </span><span style="color:#0000ff;">bool</span><span style="color:#000000;"> AddAttachment(</span><span style="color:#0000ff;">string</span><span style="color:#000000;"> filename, Guid incidentguid, </span><span style="color:#0000ff;">byte</span><span style="color:#000000;">[] modal, </span><span style="color:#0000ff;">out</span><span style="color:#000000;"> </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> errormessage)
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;">        {
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">try</span><span style="color:#000000;">
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;">            {
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">string</span><span style="color:#000000;"> encodedData </span><span style="color:#000000;">=</span><span style="color:#000000;"> Convert.ToBase64String(modal);
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">                annotation ano </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> annotation();
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">                ano.filename </span><span style="color:#000000;">=</span><span style="color:#000000;"> filename;
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">                ano.isdocument </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> Petrosea.CRM.SD.MetaUtility.CRMWebService.CrmBoolean();
</span><span style="color:#008080;">10</span> <span style="color:#000000;">                ano.isdocument.Value </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">true</span><span style="color:#000000;">;
</span><span style="color:#008080;">11</span> <span style="color:#000000;">                ano.documentbody </span><span style="color:#000000;">=</span><span style="color:#000000;"> encodedData;
</span><span style="color:#008080;">12</span> <span style="color:#000000;">                ano.mimetype </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">application/octet-stream</span><span style="color:#800000;">"</span><span style="color:#000000;">;
</span><span style="color:#008080;">13</span> <span style="color:#000000;">                ano.objectid </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> Lookup();
</span><span style="color:#008080;">14</span> <span style="color:#000000;">                ano.objectid.type </span><span style="color:#000000;">=</span><span style="color:#000000;"> EntityName.incident.ToString();
</span><span style="color:#008080;">15</span> <span style="color:#000000;">                ano.objectid.Value </span><span style="color:#000000;">=</span><span style="color:#000000;"> incidentguid;
</span><span style="color:#008080;">16</span> <span style="color:#000000;">                ano.objecttypecode </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> EntityNameReference();
</span><span style="color:#008080;">17</span> <span style="color:#000000;">                ano.objecttypecode.Value </span><span style="color:#000000;">=</span><span style="color:#000000;"> EntityName.incident.ToString();
</span><span style="color:#008080;">18</span> <span style="color:#000000;">
</span><span style="color:#008080;">19</span> <span style="color:#000000;">                TargetCreateAnnotation target </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> TargetCreateAnnotation();
</span><span style="color:#008080;">20</span> <span style="color:#000000;">                target.Annotation </span><span style="color:#000000;">=</span><span style="color:#000000;"> ano;
</span><span style="color:#008080;">21</span> <span style="color:#000000;">                CreateRequest createrequest </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">new</span><span style="color:#000000;"> CreateRequest();
</span><span style="color:#008080;">22</span> <span style="color:#000000;">                createrequest.Target </span><span style="color:#000000;">=</span><span style="color:#000000;"> target;
</span><span style="color:#008080;">23</span> <span style="color:#000000;">                CreateResponse created </span><span style="color:#000000;">=</span><span style="color:#000000;"> (CreateResponse)crmService.Execute(createrequest);
</span><span style="color:#008080;">24</span> <span style="color:#000000;">
</span><span style="color:#008080;">25</span> <span style="color:#000000;">                errormessage </span><span style="color:#000000;">=</span><span style="color:#000000;"> String.Empty;
</span><span style="color:#008080;">26</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">true</span><span style="color:#000000;">;
</span><span style="color:#008080;">27</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">28</span> <span style="color:#000000;">            </span><span style="color:#0000ff;">catch</span><span style="color:#000000;"> (Exception ex)
</span><span style="color:#008080;">29</span> <span style="color:#000000;">            {
</span><span style="color:#008080;">30</span> <span style="color:#000000;">                errormessage </span><span style="color:#000000;">=</span><span style="color:#000000;"> ex.Message;
</span><span style="color:#008080;">31</span> <span style="color:#000000;">                </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">false</span><span style="color:#000000;">;
</span><span style="color:#008080;">32</span> <span style="color:#000000;">            }
</span><span style="color:#008080;">33</span> <span style="color:#000000;">        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=19&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/06/10/crm-40-adding-attachment-notes-programmatically-to-entities/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>CRM 4.0 Plug-In: Getting Entity Id (Is it just me or? &#8230;)</title>
		<link>http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/</link>
		<comments>http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/#comments</comments>
		<pubDate>Wed, 21 May 2008 02:37:02 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[CRM]]></category>
		<category><![CDATA[Rambling]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/</guid>
		<description><![CDATA[Holla, Ok, I am new to the world of CRM 4.0 Plug-Ins, and even though I wrote many callouts for CRM 3.0, that does not count to the experience. So, I am a flat newbie [excuse mode ON]. Here&#8217;s the story; I was trying to hook to a post update event of the opportunity entity, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=18&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Holla, Ok, I am new to the world of CRM 4.0 Plug-Ins, and even though I wrote many callouts for CRM 3.0, that does not count to the experience. So, I am a flat newbie <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  [excuse mode ON].</p>
<p>Here&#8217;s the story; I was trying to hook to a <strong>post update</strong> event of the opportunity entity, and naturally wanting to do something based on the opportunityid I (<span style="text-decoration:line-through;">should have</span>) obtained easily.</p>
<p>Here&#8217;s the <span style="text-decoration:line-through;">un</span>-easy part;</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0a2b41ce-8332-4985-aa1c-96bae051d165" class="wlWriterSmartContent" style="display:inline;float:none;width:551px;margin:0;padding:0;">
<pre style="background-color:White;white-space:pre-wrap;overflow:auto;">
<div><span style="color:#000000;">Microsoft.Crm.Sdk.DynamicEntity opp </span><span style="color:#000000;">=</span><span style="color:#000000;">
          context.PostEntityImages[</span><span style="color:#800000;">"</span><span style="color:#800000;">opportunity</span><span style="color:#800000;">"</span><span style="color:#000000;">] </span><span style="color:#0000ff;">as</span><span style="color:#000000;"> Microsoft.Crm.Sdk.DynamicEntity;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>and afterwards, I could call the Id (GUID) of the opportunity like this;</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0763eac2-9f0c-4c79-8272-d3d49c3bb6da" class="wlWriterSmartContent" style="display:inline;float:none;width:567px;margin:0;padding:0;">
<pre style="background-color:White;white-space:pre-wrap;overflow:auto;">
<div><span style="color:#000000;">Microsoft.Crm.Sdk.Key okey </span><span style="color:#000000;">=</span><span style="color:#000000;">
     opp[</span><span style="color:#800000;">"</span><span style="color:#800000;">opportunityid</span><span style="color:#800000;">"</span><span style="color:#000000;">] </span><span style="color:#0000ff;">as</span><span style="color:#000000;"> Microsoft.Crm.Sdk.Key;
Guid oppid </span><span style="color:#000000;">=</span><span style="color:#000000;"> okey.Value;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Hmm&#8230; before I got here, I tried to use and register <strong>PreEntityImages</strong>, but failed. I tried to use <strong>OutputParameters</strong> of the context, and failed as well.</p>
<p>So, for post events, I&#8217;ll stick to this PostEntityImages thing.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=18&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/05/21/crm-40-plug-in-getting-entity-id-is-it-just-me-or/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>Listing Site Collections where a User got Permission (MOSS 2007 &#8211; with a lot of assumptions)</title>
		<link>http://asadewa.wordpress.com/2008/04/15/listing-site-collections-where-a-user-got-permission-moss-2007-with-a-lot-of-assumptions/</link>
		<comments>http://asadewa.wordpress.com/2008/04/15/listing-site-collections-where-a-user-got-permission-moss-2007-with-a-lot-of-assumptions/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 11:55:24 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Trivia]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/04/15/listing-site-collections-where-a-user-got-permission-moss-2007-with-a-lot-of-assumptions/</guid>
		<description><![CDATA[As usual I have a very unimportant need of getting the list of every site collections that a user has permissions on my company&#8217;s MOSS 2007 environment. The list is then to be passed to another application, for other not so important cause. My company&#8217;s site collection structure looks like:- http://rootsite- http://rootsite/sites/site01- http://rootsite/sites/site02- etc &#8230;. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=17&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As usual I have a very unimportant need of getting the list of every site collections that a user has permissions on my company&#8217;s MOSS 2007 environment. The list is then to be passed to another application, for other not so important cause.</p>
<p>My company&#8217;s site collection structure looks like:<br />- <a href="http://rootsite">http://rootsite</a><br />- <a href="http://rootsite/sites/site01">http://rootsite/sites/site01</a><br />- <a href="http://rootsite/sites/site02">http://rootsite/sites/site02</a><br />- etc &#8230;.</p>
<p>So a the list needs to list those site where a user got permission to access. (user A &#8211;&gt; site01, site02, &#8230; user B &#8211;&gt; site01, etc)</p>
<p>So, assuming that each site collection defines user permissions directly (not inside a group, which happens to be the case in my environment), I wrote this cheap thing&#8230;</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e0a900b0-0286-49b4-921a-4867d9e77bda" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">public</span><span style="color:#000000;"> List</span><span style="color:#000000;">&lt;</span><span style="color:#0000FF;">string</span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> GetValidSites(</span><span style="color:#0000FF;">string</span><span style="color:#000000;"> sitecollectionname, </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> userloginname)
        {
            SPSite sitecol </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> SPSite(sitecollectionname);
            List</span><span style="color:#000000;">&lt;</span><span style="color:#0000FF;">string</span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> siteList </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> List</span><span style="color:#000000;">&lt;</span><span style="color:#0000FF;">string</span><span style="color:#000000;">&gt;</span><span style="color:#000000;">();

            </span><span style="color:#0000FF;">foreach</span><span style="color:#000000;"> (SPSite s </span><span style="color:#0000FF;">in</span><span style="color:#000000;"> sitecol.WebApplication.Sites)
            {
                </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (s.Url.Contains(</span><span style="color:#800000;">&quot;</span><span style="color:#800000;">/sites/</span><span style="color:#800000;">&quot;</span><span style="color:#000000;">))
                {
                    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (IsAllowedFor(userloginname, s.Url))
                    {
                        siteList.Add(s.Url);
                    }
                }
            }

            </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> siteList;
        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>You get the dumbest idea just by looking at it, right? Next, we dig further;</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0b1934a3-03ae-46b2-b7ad-901f7530e228" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">bool</span><span style="color:#000000;"> IsAllowedFor(</span><span style="color:#0000FF;">string</span><span style="color:#000000;"> userloginname, </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> siteurl)
        {
            </span><span style="color:#0000FF;">bool</span><span style="color:#000000;"> result </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">false</span><span style="color:#000000;">;

            SPSite site </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> SPSite(siteurl);
            SPWeb web </span><span style="color:#000000;">=</span><span style="color:#000000;"> site.OpenWeb();

            </span><span style="color:#0000FF;">try</span><span style="color:#000000;">
            {
                SPUser usr </span><span style="color:#000000;">=</span><span style="color:#000000;"> web.AllUsers[userloginname];
                result </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">true</span><span style="color:#000000;">;
            }
            </span><span style="color:#0000FF;">catch</span><span style="color:#000000;">
            {
                result </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">false</span><span style="color:#000000;">;
            }

            </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> result;
        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Host it on web service or DLL, or whatever.<br />Then, you can call something like this on your client app:</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8d6b11d4-ca91-48f9-bb43-b27c607a8c72" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#000000;">GetValidSites(</span><span style="color:#800000;">&quot;</span><span style="color:#800000;">http://rootsite</span><span style="color:#800000;">&quot;</span><span style="color:#000000;">,</span><span style="color:#800000;">&quot;</span><span style="color:#800000;">domainname\\username</span><span style="color:#800000;">&quot;</span><span style="color:#000000;">);</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Happy? I am .. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=17&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/04/15/listing-site-collections-where-a-user-got-permission-moss-2007-with-a-lot-of-assumptions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>Removing Single File Upload Menu From Document Library Toolbar MOSS 2007</title>
		<link>http://asadewa.wordpress.com/2008/02/23/removing-single-file-upload-menu-from-document-library-toolbar-moss-2007/</link>
		<comments>http://asadewa.wordpress.com/2008/02/23/removing-single-file-upload-menu-from-document-library-toolbar-moss-2007/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 03:49:49 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[Rambling]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Trivia]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/02/23/removing-single-file-upload-menu-from-document-library-toolbar-moss-2007/</guid>
		<description><![CDATA[Well, not exactly removing, just crippling it so it won&#8217;t function. Hahah&#8230; It all began with a guy in another department who got this persistent demand of getting rid of the single file upload button from a SharePoint document library upload menu. &#8220;We can upload single file from the multiple one, no need to have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=16&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, not exactly removing, just crippling it so it won&#8217;t function. Hahah&#8230;</p>
<p>It all began with a guy in another department who got this persistent demand of getting rid of the single file upload button from a SharePoint document library upload menu. &#8220;We can upload single file from the multiple one, no need to have a single one.&#8221; He claimed. Hahah..</p>
<p>Given that I am a world-class-lazy-bum, I googled, but found that some working solutions applied globally towards the entire site collection, and not strictly to one doclib inside one site. Some claimed they have managed to do so by doing various tricks. But again, due to my acute laziness, I decided not to play around with Features, or even those object models, instead, I resorted to JavaScript.</p>
<p>What I did was described in Lazy 101; detect the Upload Menu by it&#8217;s many possible identifier (in this case i use its&#8217; &#8220;text&#8221; attribute), and brutally disabled it. I cunningly inserted a content editor webpart in the page where the doclib tool bar was visible, and chuckled in an insane glee. Mwhuahahahhahuahahahah &#8230;</p>
<p>The script is as below:</p>
<div class="wlWriterSmartContent" style="display:inline;float:none;width:574px;margin:0;padding:0;">
<pre style="overflow:auto;background-color:White;">
<div><span style="color:#000000;">&lt;</span><span style="color:#000000;">script type</span><span style="color:#000000;">=</span><span style="color:#800000;">"</span><span style="color:#800000;">text/javascript</span><span style="color:#800000;">"</span><span style="color:#000000;">&gt;</span><span style="color:#000000;">
    function GetElementByText(tagName, title)
    {
        var a </span><span style="color:#000000;">=</span><span style="color:#000000;"> document.getElementsByTagName(tagName);

        </span><span style="color:#0000ff;">for</span><span style="color:#000000;"> (var i</span><span style="color:#000000;">=</span><span style="color:#800080;">0</span><span style="color:#000000;">; i </span><span style="color:#000000;">&lt;</span><span style="color:#000000;"> a.length; i</span><span style="color:#000000;">++</span><span style="color:#000000;">)
        {
            </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (a[i].text)
            {
                </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (a[i].text </span><span style="color:#000000;">===</span><span style="color:#000000;"> title)
                {
                    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> a[i];
                }
            }
        }

        </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> </span><span style="color:#0000ff;">null</span><span style="color:#000000;">;
    }

    </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (window.onload)
    {
        var oLoad </span><span style="color:#000000;">=</span><span style="color:#000000;"> window.onload;
        window.onload </span><span style="color:#000000;">=</span><span style="color:#000000;"> function bodyLoad()
        {
            oLoad();

            var o </span><span style="color:#000000;">=</span><span style="color:#000000;"> GetElementByText(</span><span style="color:#800000;">"</span><span style="color:#800000;">ie:menuitem</span><span style="color:#800000;">"</span><span style="color:#000000;">,</span><span style="color:#800000;">"</span><span style="color:#800000;">Upload Document</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> (o)
            {
                o.disabled </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000ff;">true</span><span style="color:#000000;">;
            }
        }
    }
</span><span style="color:#000000;">&lt;/</span><span style="color:#000000;">script</span><span style="color:#000000;">&gt;</span></div>
</pre>
<pre style="overflow:auto;background-color:White;"></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>
[Update] Hey, guess what, a very kind guy has created a better tool for this (he&#8217;s even &#8220;featurize&#8221; it), check it <a href="http://scothillier.spaces.live.com/blog/cns!8F5DEA8AEA9E6FBB!280.entry">here</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=16&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/02/23/removing-single-file-upload-menu-from-document-library-toolbar-moss-2007/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>Preventing Folder Creation on MOSS 2007 Document Libraries</title>
		<link>http://asadewa.wordpress.com/2008/01/28/preventing-folder-creation-on-moss-2007-document-libraries/</link>
		<comments>http://asadewa.wordpress.com/2008/01/28/preventing-folder-creation-on-moss-2007-document-libraries/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 06:55:50 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Trivia]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/01/28/preventing-folder-creation-on-moss-2007-document-libraries/</guid>
		<description><![CDATA[Suddenly my team mate got this strange need to prevent folder creation inside MOSS document libraries. So I said &#8220;Aah .. &#8220;, and contemplated. The logic should be simple, intercept the creation process, detect if the item being added to the doclib is really a folder, and cancel the event.But the reality, the ItemAdding event [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=15&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suddenly my team mate got this strange need to prevent folder creation inside MOSS document libraries. So I said &#8220;Aah .. &#8220;, and contemplated.</p>
<p>The logic should be simple, intercept the creation process, detect if the item being added to the doclib is really a folder, and cancel the event.<br />But the reality, the ItemAdding event wouldn&#8217;t let me do the detection process.</p>
<p>So, a brutal method was then picked <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />I resorted to the ItemAdded thing, and unleashed this evil;</p>
<div class="wlWriterSmartContent" style="display:inline;float:none;width:583px;margin:0;padding:0;">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;">  ItemAdded(SPItemEventProperties properties)
        {
            </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (properties.ListItem.ContentType.Name </span><span style="color:#000000;">==</span><span style="color:#000000;"> </span><span style="color:#800000;">&quot;</span><span style="color:#800000;">Folder</span><span style="color:#800000;">&quot;</span><span style="color:#000000;">)
            {
                properties.ErrorMessage </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">&quot;</span><span style="color:#800000;">You can't create folders</span><span style="color:#800000;">&quot;</span><span style="color:#000000;">;
                properties.ListItem.Delete();
            }
        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>It worked. so stupidly enough, this will wipe the folder that you just created after detecting that the item you just added was a folder.</p>
<p>My two cents guys, who knows this might bail you out of jail too! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=15&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/01/28/preventing-folder-creation-on-moss-2007-document-libraries/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>Direct Linq to SPListItemCollection</title>
		<link>http://asadewa.wordpress.com/2008/01/03/direct-linq-to-splistitemcollection/</link>
		<comments>http://asadewa.wordpress.com/2008/01/03/direct-linq-to-splistitemcollection/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 06:49:01 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Trivia]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/01/03/direct-linq-to-splistitemcollection/</guid>
		<description><![CDATA[This one&#8217;s a sequel to my last post about LINQ-ize a SPListCollection. I got another not-so-important urge to get a maximum number from one of my custom list&#8217;s field. Let&#8217;s just say the the field containing the number is &#8220;Document Number&#8221;, and I want to grab the current maximum value of that field to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=14&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This one&#8217;s a sequel to my last post about LINQ-ize a SPListCollection.<br />
I got another not-so-important urge to get a maximum number from one of my custom list&#8217;s field.<br />
Let&#8217;s just say the the field containing the number is &#8220;Document Number&#8221;, and I want to grab the current maximum value of that field to do various purposes.</p>
<p>Now, as I am a little bit obsessed with Linq, so let&#8217;s leave CAML behind and grab Linq instead.<br />
Let&#8217;s begin by creating a wrapper around SPListItemCollection object to make it Linq-able (just like I did with the SPListCollection).</p>
<blockquote><p>public class SPListItemCollectionAdapter : List&lt;SPListItem&gt;<br />
{<br />
private SPListItemCollection _listItemCollection;</p>
<p>public SPListItemCollectionAdapter(SPListItemCollection listItemCollection)<br />
{<br />
_listItemCollection = listItemCollection;</p>
<p>Refresh();<br />
}</p>
<p>private void Refresh()<br />
{<br />
this.Clear();</p>
<p>foreach (SPListItem item in _listItemCollection)<br />
{<br />
this.Add(item);<br />
}<br />
}</p>
<p>}</p></blockquote>
<p>then voila!, you can use Linq&#8217;s aggregation function to grab the max value currently on a field called &#8220;Document Number&#8221; inside a list called &#8220;Document&#8221;. Write a method that might look like this:</p>
<blockquote><p> <code>private static double GetMaxFrom(string listname, string fieldname)<br />
{<br />
SPListItemCollection itemcol = mossWeb.Lists[listname].Items;<br />
SPListItemCollectionAdapter itemsAdapter = new SPListItemCollectionAdapter(itemcol);<br />
var result = itemsAdapter.Max(x =&gt; x[fieldname]);<br />
return (double)result;<br />
}</code></p></blockquote>
<p><code><b>mossWeb</b></code> is just a singleton for the SPWeb object, as I was using it numerous times on other methods as well.<br />
I also took the liberty of using the lambda expression <code>(x =&gt; x[fieldname])</code> just to evaluate the specific field.<br />
Using it is as easy as calling <code>GetMaxFrom("Document","Document Number")</code>;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=14&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/01/03/direct-linq-to-splistitemcollection/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ-ing SPListCollection</title>
		<link>http://asadewa.wordpress.com/2008/01/03/linq-ing-splistcollection/</link>
		<comments>http://asadewa.wordpress.com/2008/01/03/linq-ing-splistcollection/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 04:49:23 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Trivia]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2008/01/03/linq-ing-splistcollection/</guid>
		<description><![CDATA[After trying this LINQToSharePoint, I must admit I was a bit carried away in forcing Linq to my SharePoint programming needs. I had this one very &#8220;not so important&#8221; ambition of iterating through SPList object within the SPListCollection on a SPWeb object. Problem popped out, SPListCollection was not implementing IEnumerable, so I could not walk [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=13&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After trying this <a href="http://www.codeplex.com/linqtosharepoint">LINQToSharePoint</a>, I must admit I was a bit carried away in forcing Linq to my SharePoint programming needs.<br />
I had this one very &#8220;not so important&#8221; ambition of iterating through SPList object within the SPListCollection on a SPWeb object.<br />
Problem popped out, SPListCollection was not implementing IEnumerable, so I could not walk easily using Linq to this collection.<br />
So.. to fulfill my ambition, I created a pseudo-adapter class which looked like this:</p>
<blockquote><p> public class SPListCollectionAdapter : List&lt;SPList&gt;<br />
{<br />
private SPListCollection _listCol;</p>
<p>public SPListCollectionAdapter(SPListCollection listCol)<br />
{<br />
_listCol = listCol;</p>
<p>Refresh();<br />
}</p>
<p>private void Refresh()<br />
{<br />
this.Clear();</p>
<p>foreach (SPList item in _listCol)<br />
{<br />
this.Add(item);<br />
}<br />
}<br />
}</p></blockquote>
<p>and shortly after that, I could then satisfy my quaint hunger with this method:</p>
<blockquote><p> private static void DoMOSSLinq()<br />
{<br />
SPSite site = new SPSite(&#8220;http://titanctp2:9000&#8243;);<br />
SPWeb web = site.AllWebs[0];</p>
<p>SPListCollectionAdapter listAdapter = new SPListCollectionAdapter(web.Lists);</p>
<p>var result = from l in listAdapter<br />
select l;</p>
<p>foreach (var i in result)<br />
Console.WriteLine(i.Title);</p>
<p>Console.ReadLine();<br />
}</p></blockquote>
<p>woohooo!!! I am no longer hungry.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=13&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2008/01/03/linq-ing-splistcollection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
		<item>
		<title>First Encounter of the LINQ Kind</title>
		<link>http://asadewa.wordpress.com/2007/12/19/first-encounter-of-the-linq-kind/</link>
		<comments>http://asadewa.wordpress.com/2007/12/19/first-encounter-of-the-linq-kind/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 10:24:33 +0000</pubDate>
		<dc:creator>Asfar Sadewa</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Rambling]]></category>

		<guid isPermaLink="false">http://asadewa.wordpress.com/2007/12/19/first-encounter-of-the-linq-kind/</guid>
		<description><![CDATA[I got an XML document that looks like this. &#60;AreaList&#62; &#60;Area id=&#8221;1&#8243;&#62; &#60;name&#62;Brave Land&#60;/name&#62; &#60;description&#62;An area where the brave may live forever&#60;/description&#62; &#60;/Area&#62; &#60;/AreaList&#62; Now, if I want to search and fetch the text inside the &#8220;name&#8221; tag based on a supplied &#8220;id&#8221;, I can rely faithfully on LINQ. XDocument doc = XDocument.Load(PATH_TO_XML_DOCUMENT); var x [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=12&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I got an XML document that looks like this.</p>
<blockquote><p>&lt;AreaList&gt;<br />
&lt;Area id=&#8221;1&#8243;&gt;<br />
&lt;name&gt;Brave Land&lt;/name&gt;<br />
&lt;description&gt;An area where the brave may live forever&lt;/description&gt;<br />
&lt;/Area&gt;<br />
&lt;/AreaList&gt;</p></blockquote>
<p>Now, if I want to search and fetch the text inside the  &#8220;name&#8221; tag based on a supplied &#8220;id&#8221;, I can rely faithfully on LINQ.</p>
<blockquote><p>XDocument doc = XDocument.Load(PATH_TO_XML_DOCUMENT);<br />
var x = from area in doc.Descendants(&#8220;Area&#8221;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where (int)area.Attribute(&#8220;id&#8221;) == MY_SUPPLIED_ID<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select (string)area.Element(&#8220;name&#8221;);</p></blockquote>
<p>and consume it using <strong>x.First()</strong></p>
<p>aaah &#8230;. how readable, how lovely, Nirvana!!!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asadewa.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asadewa.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asadewa.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asadewa.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asadewa.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asadewa.wordpress.com&amp;blog=2135763&amp;post=12&amp;subd=asadewa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asadewa.wordpress.com/2007/12/19/first-encounter-of-the-linq-kind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/368890b2dbcd4fedab40c6ac953464ee?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Asfar</media:title>
		</media:content>
	</item>
	</channel>
</rss>
