<?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>Arvindcsit's Weblog</title>
	<atom:link href="http://arvindcsit.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://arvindcsit.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 20 Jan 2009 19:47:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='arvindcsit.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b66d65742a8facb5f459faad59db0521?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Arvindcsit's Weblog</title>
		<link>http://arvindcsit.wordpress.com</link>
	</image>
			<item>
		<title>PlugIn Impersonation In Microsoft Dynamics CRM 4.0(i.e Executing plugin code on behalf of another user.)</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/plugin-impersonation-in-microsoft-dynamics-crm-40ie-executing-plugin-code-on-behalf-of-another-user/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/plugin-impersonation-in-microsoft-dynamics-crm-40ie-executing-plugin-code-on-behalf-of-another-user/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 19:47:09 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=57</guid>
		<description><![CDATA[If we want to execute some code in behalf of another user not the calling user then we have to handle this in PlugIn code. Whatever the user selected during PlugIns registration, it doesn’t matter, code will alwaysexecute on behalf of user mentioned in code.Example Create a Record in CRM on behalf of another user.
 
try
                            [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=57&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;">If we want to execute some code in behalf of another user not the calling user then we have to handle this in PlugIn code. Whatever the user selected during PlugIns registration, it doesn’t matter, code will alwaysexecute on behalf of user mentioned in code.Example <span style="color:red;">Create a Record in CRM on behalf of another user</span>.</span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;">try</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                            </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>CrmSdk.CrmAuthenticationToken token = new CrmSdk.CrmAuthenticationToken();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>      </span><span>                          </span>token.AuthenticationType = 0;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                   </span><span>             </span>token.OrganizationName = OrganizationName;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;">                               </span></span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>// Create CrmService instance</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                           </span><span>     </span>CrmSdk.CrmService service= new CrmSdk.CrmService();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                 </span><span>               </span>service.Url = CrmServiceUrl;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>        </span><span>                        </span>service.CrmAuthenticationTokenValue = token;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>//execute on behalf of another user</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>        </span><span>                        </span><strong><span style="color:#003366;">service.Credentials = new System.Net.NetworkCredential(“username”,”password”,”domain”);</span></strong></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>//service.CorrelationTokenValue = correlationToken;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>//Create Proposal record</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>   </span><span>                             </span>CrmSdk.new_proposal proposal = new CrmSdk.new_proposal();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;">                                </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>// set value of Opportunity Lookup in Proposal entity.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>CrmSdk.Lookup oppLookup = new CrmSdk.Lookup();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>oppLookup.type = EntityName.opportunity.ToString();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>oppLookup.Value = new Guid(oppId);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                                </span>proposal.new_opportunityid = oppLookup;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>        </span><span>                        </span>service.Create(proposal);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>              </span><span>              </span>}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                            </span>catch (SoapException ex)</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                            </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                               // show message here.. </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"></span><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>                            </span>}</span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=57&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/plugin-impersonation-in-microsoft-dynamics-crm-40ie-executing-plugin-code-on-behalf-of-another-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Error Importing custom entity in Microsoft Dynamics CRM 4.0</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/error-importing-custom-entity-in-microsoft-dynamics-crm-40/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/error-importing-custom-entity-in-microsoft-dynamics-crm-40/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 19:24:41 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=54</guid>
		<description><![CDATA[While importing custom entity from one deployment to another deployment we are receiving this error
 
Failure: EntityName_BulkDeleteFailures: A SQL Server error occurred. Try this action again. If the problem….. 
 
Resolution for this issue: I exported the customizations and removed the system reference to &#8220;BulkDeleteFailures&#8221; in xml before importing it. It works but it is unsupported.
  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=54&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;">While importing custom entity from one deployment to another deployment we are receiving this error</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><strong><span style="color:red;">Failure: EntityName_BulkDeleteFailures: A SQL Server error occurred. Try this action again</span></strong>. <strong><span style="color:red;">If the problem</span></strong>….. </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:10pt;color:#003366;font-family:Arial;">Resolution for this issue</span></strong><span style="font-size:10pt;color:black;font-family:Arial;">: I exported the customizations and removed the system reference to &#8220;BulkDeleteFailures&#8221; in xml before importing it. It works but it is unsupported.</span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=54&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/error-importing-custom-entity-in-microsoft-dynamics-crm-40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Handling SOAP Exceptions In Microsoft Dynamics CRM</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/handling-soap-exceptions-in-microsoft-dynamics-crm/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/handling-soap-exceptions-in-microsoft-dynamics-crm/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 18:03:13 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=52</guid>
		<description><![CDATA[The only exception thrown by the CRM Web service is a common
SoapException whose message property is always “Server was unable to process
request.”
 
To handle that exception, catch the exception and display the InnerXml error
code, error text, and error description
 
Example
 
try
{
// Delete the non-existent Contact
service.Delete(EntityName.contact.ToString(), contactGuid);
}
catch (SoapException ex)
{
// This will contain the error message from the platform
Console.WriteLine(&#8220;Microsoft Dynamics [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=52&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">The only exception thrown by the CRM Web service is a common</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">SoapException whose message property is always “Server was unable to process</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">request.”</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">To handle that exception, catch the exception and display the InnerXml error</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">code, error text, and error description</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:red;font-family:Verdana;"><span style="font-size:small;">Example</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">try</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Delete the non-existent Contact</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Delete(EntityName.contact.ToString(), contactGuid);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">catch (SoapException ex)</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// This will contain the error message from the platform</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Console.WriteLine(&#8220;Microsoft Dynamics CRM Error</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Information:&#8221;);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Console.WriteLine(ex.Detail.InnerText);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// The InnerXml contains the details of the error in a</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">parsable XML format</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">XmlDocument error = new XmlDocument();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">error.LoadXml(ex.Detail.InnerXml);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Render out the details of the error</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Console.WriteLine(&#8220;Error Code: &#8221; +</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">error.SelectSingleNode(&#8220;/error/code&#8221;).InnerText);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Console.WriteLine(&#8220;Error Description: &#8221; +</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">error.SelectSingleNode(&#8220;/error/description&#8221;).InnerText);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Console.WriteLine(&#8220;Error Type: &#8221; +</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">error.SelectSingleNode(&#8220;/error/type&#8221;).InnerText);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=52&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/handling-soap-exceptions-in-microsoft-dynamics-crm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the RetrieveMultiple Method in Microsoft Dynamics CRM 4.0</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/using-the-retrievemultiple-method-in-microsoft-dynamics-crm-40/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/using-the-retrievemultiple-method-in-microsoft-dynamics-crm-40/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 18:01:02 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=50</guid>
		<description><![CDATA[// Set up the CRM Service.
CrmAuthenticationToken token = new
CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get
the enumeration for AD Authentication.
token.AuthenticationType = 0;
token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;
CrmService service = new CrmService();
service.Url
=&#8221;http://&#60;servername&#62;:&#60;port&#62;/mscrmservices/2007/crmservice.
asmx&#8221;;
service.CrmAuthenticationTokenValue = token;
service.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Create the ColumnSet indicating the properties to be
retrieved
ColumnSet cols = new ColumnSet();
// Sets the ColumnSet&#8217;s Properties
cols.Attributes = new string [] {&#8220;fullname&#8221;, &#8220;contactid&#8221;};
// [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=50&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set up the CRM Service.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken token = new</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// You can use enums.cs from the SDK\Helpers folder to get</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">the enumeration for AD Authentication.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.AuthenticationType = 0;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmService service = new CrmService();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Url</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">=&#8221;http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">asmx&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.CrmAuthenticationTokenValue = token;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Credentials =</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">System.Net.CredentialCache.DefaultCredentials;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the ColumnSet indicating the properties to be</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">retrieved</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">ColumnSet cols = new ColumnSet();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Sets the ColumnSet&#8217;s Properties</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">cols.Attributes = new string [] {&#8220;fullname&#8221;, &#8220;contactid&#8221;};</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the ConditionExpression</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">ConditionExpression condition = new ConditionExpression();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set the Condition for the Retrieval to be when the</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact&#8217;s address&#8217; city is Sammamish</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">condition.AttributeName =&#8221;address1_city&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">condition.Operator = ConditionOperator.Like;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">condition.Values = new string [] {&#8220;Sammamish&#8221;};</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the FilterExpression</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">FilterExpression filter = new FilterExpression();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set the Filter&#8217;s Properties</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">filter.FilterOperator = LogicalOperator.And;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">filter.Conditions = new ConditionExpression[] {condition};</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the QueryExpression Object</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">QueryExpression query = new QueryExpression();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set the QueryExpression Object&#8217;s Properties</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">query.EntityName = EntityName.contact.ToString();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">query.ColumnSet = cols;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">query.Criteria = filter;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Retrieve the Contacts</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">BusinessEntityCollection contacts =</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.RetrieveMultiple(query);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:'Courier New';"><span style="font-size:small;"> </span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=50&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/using-the-retrievemultiple-method-in-microsoft-dynamics-crm-40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Update Method of CrmService WebService</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/using-update-method-of-crmservice-webservice/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/using-update-method-of-crmservice-webservice/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:55:47 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=46</guid>
		<description><![CDATA[// Set up the CRM Service.
CrmAuthenticationToken token = new
CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get
the enumeration for AD Authentication.
token.AuthenticationType = 0;
token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;
CrmService service = new CrmService();
service.Url
=&#8221;http://&#60;servername&#62;:&#60;port&#62;/mscrmservices/2007/crmservice.
asmx&#8221;;
service.CrmAuthenticationTokenValue = token;
service.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Create the contact object.
contact contact = new contact();
// Set the contact object properties to be updated.
contact.address1_line1 =&#8221;34 Market St.&#8221;;
// The contactid is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=46&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set up the CRM Service.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken token = new</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// You can use enums.cs from the SDK\Helpers folder to get</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">the enumeration for AD Authentication.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.AuthenticationType = 0;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmService service = new CrmService();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Url</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">=&#8221;http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">asmx&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.CrmAuthenticationTokenValue = token;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Credentials =</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">System.Net.CredentialCache.DefaultCredentials;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the contact object.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact contact = new contact();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set the contact object properties to be updated.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact.address1_line1 =&#8221;34 Market St.&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// The contactid is a key that references the ID of the</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact to be updated.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact.contactid = new Key();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// The contactid.Value is the GUID of the record to be</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">changed.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact.contactid.Value = new Guid(&#8220;4D507FFE-ED25-447B-</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">80DE-00AE3EB18B84&#8243;);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Update the contact.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Update(contact);</span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=46&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/using-update-method-of-crmservice-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Delete Method of CrmService WebService</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/using-delete-method-of-crmservice-webservice/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/using-delete-method-of-crmservice-webservice/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:51:03 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=42</guid>
		<description><![CDATA[// Deletes the Contact
// The EntityName indicates the
// EntityType of the Object being deleted.
service.Delete(EntityName.contact.ToString(),
myContact.contactid);
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=42&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Deletes the Contact</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// The EntityName indicates the</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// EntityType of the Object being deleted.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Delete(EntityName.contact.ToString(),</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">myContact.contactid);</span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=42&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/using-delete-method-of-crmservice-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Create Method of CrmService WebService</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/using-create-method-of-crmservice-webservice/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/using-create-method-of-crmservice-webservice/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:41:22 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=37</guid>
		<description><![CDATA[// Set up the CRM Service.
CrmAuthenticationToken token = new
CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get
the enumeration for AD Authentication.
token.AuthenticationType = 0;
token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;
CrmService service = new CrmService();
service.Url
=&#8221;http://&#60;servername&#62;:&#60;port&#62;/mscrmservices/2007/crmservice.
asmx&#8221;;
service.CrmAuthenticationTokenValue = token;
service.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Create the column set object that indicates the
properties to be retrieved.
ColumnSet cols = new ColumnSet();
// Set the properties of the column set.
cols.Attributes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=37&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set up the CRM Service.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken token = new</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmAuthenticationToken();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// You can use enums.cs from the SDK\Helpers folder to get</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">the enumeration for AD Authentication.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.AuthenticationType = 0;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">token.OrganizationName =&#8221;AdventureWorksCycle&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">CrmService service = new CrmService();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Url</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">=&#8221;http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">asmx&#8221;;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.CrmAuthenticationTokenValue = token;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">service.Credentials =</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">System.Net.CredentialCache.DefaultCredentials;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Create the column set object that indicates the</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">properties to be retrieved.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">ColumnSet cols = new ColumnSet();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Set the properties of the column set.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">cols.Attributes = new string [] {&#8220;fullname&#8221;};</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// contactGuid is the GUID of the record being retrieved.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Guid contactGuid = new Guid(&#8220;4D507FFE-ED25-447B-80DE-</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">00AE3EB18B84&#8243;);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// Retrieve the contact.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">// The EntityName indicates the EntityType of the object</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">being retrieved.</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contact contact =</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">(contact)service.Retrieve(EntityName.contact.ToString(),</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">contactGuid, cols);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:'Courier New';"><span style="font-size:small;"> </span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=37&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/using-create-method-of-crmservice-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the CrmDiscoveryService Web Service In CRM4.0: On-Premise</title>
		<link>http://arvindcsit.wordpress.com/2009/01/20/using-the-crmdiscoveryservice-web-service-in-crm40-on-premise/</link>
		<comments>http://arvindcsit.wordpress.com/2009/01/20/using-the-crmdiscoveryservice-web-service-in-crm40-on-premise/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:22:53 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/?p=31</guid>
		<description><![CDATA[CrmDiscovery service is a global installable level service that allow the caller to determine the correct organization and URL for his/her need.
Below example show how to create and configure CrmDiscoveryService Web Service proxy.
 
// Create and configure the CrmDiscoveryService Web service
proxy.
CrmDiscoveryService discoveryService = new
CrmDiscoveryService();
discoveryService.UseDefaultCredentials = true;
discoveryService.Url
=&#8221;http://localhost/MSCRMServices/2007/AD/CrmDiscoveryServic
e.asmx&#8221;;
// Retrieve the list of organizations that the logged on
user belongs [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=31&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2 class="MsoNormal" style="margin:0;"><span style="font-size:13pt;font-family:Verdana;"><span style="color:#003366;">CrmDiscovery service is a global installable level service that allow the caller to determine the correct organization and URL for his/her need.</span></span></h2>
<h2 class="MsoNormal" style="margin:0;"><span style="font-size:13pt;font-family:Verdana;"><span style="color:#003366;">Below example show how to create and configure CrmDiscoveryService Web Service proxy.</span></span></h2>
<h2 class="MsoNormal" style="margin:0;"><span style="font-size:13pt;font-family:&quot;"> </span></h2>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">// Create and configure the CrmDiscoveryService Web service</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">proxy.</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">CrmDiscoveryService discoveryService = new</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">CrmDiscoveryService();</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">discoveryService.UseDefaultCredentials = true;</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">discoveryService.Url</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">=&#8221;http://localhost/MSCRMServices/2007/AD/CrmDiscoveryServic</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">e.asmx&#8221;;</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">// Retrieve the list of organizations that the logged on</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">user belongs to.</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">RetrieveOrganizationsRequest orgRequest = new</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">RetrieveOrganizationsRequest();</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">RetrieveOrganizationsResponse orgResponse =</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">(RetrieveOrganizationsResponse)discoveryService.Execute(org</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">Request);</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">// Locate the target organization in the list.</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">OrganizationDetail orgInfo = null;</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">foreach (OrganizationDetail orgDetail in</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">orgResponse.OrganizationDetails)</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">{</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">if</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">(orgDetail.OrganizationName.Equals(&#8220;AdventureWorksCycle&#8221;))</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">{</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">orgInfo = orgDetail;</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">break;</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">}</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">}</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">// Check whether a matching organization was not found.</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">if (orgInfo == null)</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">throw new Exception(&#8220;The specified organization was not</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;">found.&#8221;);</span></span></h4>
<h4 class="MsoNormal" style="margin:0;"><span style="font-family:Verdana;"><span style="color:#333333;"> </span></span></h4>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=31&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2009/01/20/using-the-crmdiscoveryservice-web-service-in-crm40-on-premise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating AutoNumber for Microsoft Dynamics CRM 4.0 using Plug-Ins with the help of FilteredView</title>
		<link>http://arvindcsit.wordpress.com/2008/12/22/creating-autonumber-for-microsoft-dynamics-crm-40-using-plug-ins-with-the-help-of-filteredview/</link>
		<comments>http://arvindcsit.wordpress.com/2008/12/22/creating-autonumber-for-microsoft-dynamics-crm-40-using-plug-ins-with-the-help-of-filteredview/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 10:20:12 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[AutoNumber]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/2008/12/22/creating-autonumber-for-microsoft-dynamics-crm-40-using-plug-ins-with-the-help-of-filteredview/</guid>
		<description><![CDATA[Create two field as we created..
1) New_uniqueid ( Int)
2) New_id( nvarchar).
 
If you want AutoNumber as Int , no need to create two fields ,but we wanted AutoNumber as in specific format(OP/DEC08/0000000001) so we reqired to two field.
 
Steps for AutoNumber:
1) Retrieved the maximum number for entity based on  field new_uniqueid.
2) Update both field [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=28&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal"><span style="font-size:12pt;line-height:115%;">Create two field as we created..</span></p>
<p class="MsoListParagraphCxSpFirst" style="text-indent:-.25in;"><!--[if !supportLists]--><span style="font-size:12pt;line-height:115%;"><span>1)<span style="font-family:&quot;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;"> </span></span></span><!--[endif]--><span style="font-size:12pt;line-height:115%;">New_uniqueid ( Int)</span></p>
<p class="MsoListParagraphCxSpMiddle" style="text-indent:-.25in;"><!--[if !supportLists]--><span style="font-size:12pt;line-height:115%;"><span>2)<span style="font-family:&quot;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;"> </span></span></span><!--[endif]--><span style="font-size:12pt;line-height:115%;">New_id( nvarchar).</span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size:12pt;line-height:115%;"> </span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size:12pt;line-height:115%;">If you want AutoNumber as Int , no need to create two fields ,but we wanted AutoNumber<span> </span>as in specific format(OP/DEC08/0000000001) so we reqired to two field.</span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size:12pt;line-height:115%;"> </span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size:12pt;line-height:115%;">Steps for AutoNumber:</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:.75in;text-indent:-.25in;"><!--[if !supportLists]--><span style="font-size:12pt;line-height:115%;"><span>1)<span style="font-family:&quot;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;"> </span></span></span><!--[endif]--><span style="font-size:12pt;line-height:115%;">Retrieved the maximum number for entity based on <span> </span>field new_uniqueid.</span></p>
<p class="MsoListParagraphCxSpLast" style="margin-left:.75in;text-indent:-.25in;"><!--[if !supportLists]--><span style="font-size:12pt;line-height:115%;"><span>2)<span style="font-family:&quot;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;"> </span></span></span><!--[endif]--><span style="font-size:12pt;line-height:115%;">Update both field new_uniqueid and new_id using web service on PostCreate event.</span></p>
<p class="MsoNormal"><span style="font-size:12pt;line-height:115%;">Source Code</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Collections.Generic;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Text;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Xml;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Xml.Serialization;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.IO;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Collections;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> Microsoft.Crm.Sdk;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Data;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Data.SqlClient;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">using</span><span style="font-size:12pt;font-family:&quot;"> System.Web.Services.Protocols;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">namespace</span><span style="font-size:12pt;font-family:&quot;"> CRM.PlugIn.UniqueIdGeneration</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">PlugInForUniqueId</span> : <span style="color:#2b91af;">IPlugin</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> serverName = <span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> domain = <span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> authUser = <span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">int</span> leftPad;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> uniqueNoField=<span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> uniqueIdField=<span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">static</span> <span style="color:blue;">string</span> logPath = <span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:green;">// get configuration string</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">public</span><span style="font-size:12pt;font-family:&quot;"> PlugInForUniqueId(<span style="color:blue;">string</span> unsecure, <span style="color:blue;">string</span> secureConfiguration)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlDataDocument</span><span style="font-size:12pt;font-family:&quot;"> doc = <span style="color:blue;">new</span> <span style="color:#2b91af;">XmlDataDocument</span>();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">doc.LoadXml(secureConfiguration);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get database server name</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> database = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//Database&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">serverName= database.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get domain name</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> domainName = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//Domain&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">domain = domainName.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// CRM User as Authentication User</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> authUserName = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//AuthUser&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">authUser = authUserName.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get total no of digit for padding</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> padding = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//Padding&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">leftPad=<span style="color:#2b91af;">Convert</span>.ToInt32( padding.InnerText);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get FieldName and type of datatype should be Integer</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> uniqueNo = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//UniqueNumber&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">uniqueNoField= uniqueNo.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get FieldName and type of datatype should be nvarchar</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> Id = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//Id&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">uniqueIdField= Id.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:green;">// get path of log file.</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">XmlNode</span><span style="font-size:12pt;font-family:&quot;"> Log = doc.SelectSingleNode(<span style="color:#a31515;">&#8220;//LogPath&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">logPath = Log.InnerText;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">public</span> <span style="color:blue;">void</span> Execute(<span style="color:#2b91af;">IPluginExecutionContext</span> context)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:green;">// Create instance of Crm WenService</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">ICrmService</span> Service = context.CreateCrmService(<span style="color:blue;">true</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> entityName = context.PrimaryEntityName;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> orgName = context.OrganizationName;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:green;">// Avialable max. number in database.</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">int</span> maxUniqueNo = ReturnMaxNumber(serverName, entityName, orgName);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">CrmNumber</span> num = <span style="color:blue;">new</span> <span style="color:#2b91af;">CrmNumber</span>();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>num.Value = maxUniqueNo;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:green;">// Formatted Unique Id With entityname,month,year and unique No.</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> formattedId = FormattedUniqueNumber(num.Value, context.PrimaryEntityName);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:green;">// DynamicEntity dyEntity = ReturnDynamicEntityToUpate(context, num);</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">if</span> (context.InputParameters.Properties.Contains(<span style="color:#a31515;">&#8220;Target&#8221;</span>))</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">DynamicEntity</span> entity = (<span style="color:#2b91af;">DynamicEntity</span>)context.InputParameters.Properties[<span style="color:#a31515;">"Target"</span>];</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">if</span> (entity != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> entityId = context.PrimaryEntityName + <span style="color:#a31515;">&#8220;id&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:#2b91af;">Guid</span> id = (<span style="color:#2b91af;">Guid</span>)context.OutputParameters[<span style="color:#2b91af;">ParameterName</span>.Id];</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:#2b91af;">DynamicEntity</span> updateUniqueId = <span style="color:blue;">new</span> <span style="color:#2b91af;">DynamicEntity</span>(context.PrimaryEntityName);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">Key</span> key = <span style="color:blue;">new</span> <span style="color:#2b91af;">Key</span>(id);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">KeyProperty</span> keyProp = <span style="color:blue;">new</span> <span style="color:#2b91af;">KeyProperty</span>(entityId, key);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>updateUniqueId.Properties.Add(keyProp);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">CrmNumberProperty</span> propUniqueId = <span style="color:blue;">new</span> <span style="color:#2b91af;">CrmNumberProperty</span>(uniqueNoField, num);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 .0001pt .5in;"><span style="font-size:12pt;font-family:&quot;"><span> </span>updateUniqueId.Properties.Add(propUniqueId);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 .0001pt 28.5pt;"><span style="font-size:12pt;font-family:&quot;color:#2b91af;">StringProperty</span><span style="font-size:12pt;font-family:&quot;"> propFormattedId = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringProperty</span>(uniqueIdField, formattedId);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 .0001pt 28.5pt;"><span style="font-size:12pt;font-family:&quot;"><span> </span>updateUniqueId.Properties.Add(propFormattedId);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>Service.Update(updateUniqueId);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">SoapException</span> SoapEx)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>WriteLog(entityName, <span style="color:#a31515;">&#8220;On Create&#8221;</span>,<span style="color:#a31515;">&#8220;ERROR&#8221;</span>,SoapEx);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>WriteLog(entityName, <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;ERROR&#8221;</span>, ex.Message);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">private</span><span style="font-size:12pt;font-family:&quot;"> <span style="color:blue;">int</span> ReturnMaxNumber(<span style="color:blue;">string</span> server, <span style="color:blue;">string</span> entity, <span style="color:blue;">string</span> orgName)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">int</span> maxNum = 0;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> dataSource = server;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> tableView = <span style="color:#a31515;">&#8220;Filtered&#8221;</span> + entity;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> organizatioName = orgName ;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> databaseName = organizatioName + <span style="color:#a31515;">&#8220;_MSCRM&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;"><span> </span>string</span><span style="font-size:12pt;font-family:&quot;"> sqlQuery = <span style="color:#a31515;">@&#8221; SETUSER &#8216;&#8221;</span>+domain +<span style="color:#a31515;">&#8220;\\&#8221;</span>+ authUser + <span style="color:#a31515;">&#8220;&#8216; select max(new_uniqueid) from &#8220;</span> + tableView ;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>WriteLog(entity , <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;INFO&#8221;</span>, <span style="color:#a31515;">&#8220;DatabaseServer :&#8221;</span> + dataSource);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>WriteLog(entity, <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;INFO&#8221;</span>, <span style="color:#a31515;">&#8220;Sql Query :&#8221;</span> + sqlQuery);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:#2b91af;">SqlConnection</span> connection = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(<span style="color:#a31515;">&#8220;Data Source=&#8221;</span> + dataSource + <span style="color:#a31515;">&#8220;;Initial Catalog=&#8221;</span> + databaseName + <span style="color:#a31515;">&#8220;;Integrated Security=SSPI; Pooling=false&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:#2b91af;">SqlCommand</span> cmd = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>(sqlQuery, connection);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>connection.Open();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">if</span> (cmd.ExecuteScalar().ToString() != <span style="color:#a31515;">&#8220;&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>maxNum = <span style="color:#2b91af;">Convert</span>.ToInt32(cmd.ExecuteScalar());</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>connection.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>connection.Dispose();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">if</span> (maxNum &gt; 0)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span> </span>maxNum++;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">else</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>maxNum = 1;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">SqlException</span> sqlex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>WriteLog(entity, <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;ERROR&#8221;</span>, sqlex);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>maxNum =0;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">return</span> maxNum;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">private</span> <span style="color:blue;">string</span> FormattedUniqueNumber(<span style="color:blue;">int</span> num, <span style="color:blue;">string</span> entity)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> finalUniqueNo=<span style="color:blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">DateTime</span> currentDate = <span style="color:#2b91af;">DateTime</span>.Now;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> getMonth = currentDate.ToString(<span style="color:#a31515;">&#8220;MMM&#8221;</span>).ToUpper();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> getYear = currentDate.Year.ToString().Substring(2, 2);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> numWithPad = num.ToString().PadLeft(leftPad, <span style="color:#a31515;">&#8216;0&#8242;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> entiyName = entity.Substring(0, 2).ToUpper();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>finalUniqueNo = entiyName + <span style="color:#a31515;">&#8220;/&#8221;</span> + getMonth + getYear + <span style="color:#a31515;">&#8220;/&#8221;</span> + numWithPad;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>WriteLog(entity, <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;INFO&#8221;</span>, <span style="color:#a31515;">&#8220;Unique ID=&#8221;</span> + finalUniqueNo);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">return</span> finalUniqueNo;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>WriteLog(entity, <span style="color:#a31515;">&#8220;On Create&#8221;</span>, <span style="color:#a31515;">&#8220;ERROR&#8221;</span>, ex.Message);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">return</span> finalUniqueNo;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal"><span style="font-size:12pt;line-height:115%;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:blue;">private</span><span style="font-size:12pt;font-family:&quot;"> <span style="color:blue;">static</span> <span style="color:blue;">void</span> WriteLog(<span style="color:blue;">string</span> Entity, <span style="color:blue;">string</span> EventName, <span style="color:blue;">string</span> MessageType, <span style="color:#2b91af;">SoapException</span> ex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> lstrMessage;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">TextWriter</span> log = <span style="color:#2b91af;">TextWriter</span>.Synchronized(<span style="color:#2b91af;">File</span>.AppendText(logPath));</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>lstrMessage = Entity + <span style="color:#a31515;">&#8221; | &#8220;</span> + EventName + <span style="color:#a31515;">&#8221; | &#8220;</span> + MessageType + <span style="color:#a31515;">&#8221; | &#8220;</span> + System.<span style="color:#2b91af;">DateTime</span>.Now.ToString () + <span style="color:#a31515;">&#8221; | &#8220;</span> + ex.Detail.InnerXml;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>log.WriteLine(lstrMessage);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>log.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex1)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">throw</span> ex1;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> WriteLog(<span style="color:blue;">string</span> Entity, <span style="color:blue;">string</span> EventName, <span style="color:blue;">string</span> MessageType, <span style="color:blue;">string</span> Message)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> lstrMessage;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:#2b91af;">TextWriter</span> log = <span style="color:#2b91af;">TextWriter</span>.Synchronized(<span style="color:#2b91af;">File</span>.AppendText(logPath));</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>lstrMessage = Entity + <span style="color:#a31515;">&#8221; | &#8220;</span> + EventName + <span style="color:#a31515;">&#8221; | &#8220;</span> + MessageType + <span style="color:#a31515;">&#8221; | &#8220;</span> + System.<span style="color:#2b91af;">DateTime</span>.Now.ToString () + <span style="color:#a31515;">&#8221; | &#8220;</span> + Message ;<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>log.WriteLine(lstrMessage );</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>log.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">throw</span> ex;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> WriteLog(<span style="color:blue;">string</span> Entity, <span style="color:blue;">string</span> EventName, <span style="color:blue;">string</span> MessageType, <span style="color:#2b91af;">SqlException</span> Message)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>{<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> lstrMessage;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:#2b91af;">TextWriter</span> log = <span style="color:#2b91af;">TextWriter</span>.Synchronized(<span style="color:#2b91af;">File</span>.AppendText(logPath));</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>lstrMessage = Entity + <span style="color:#a31515;">&#8221; | &#8220;</span> + EventName + <span style="color:#a31515;">&#8221; | &#8220;</span> + MessageType + <span style="color:#a31515;">&#8221; | &#8220;</span> + System.<span style="color:#2b91af;">DateTime</span>.Now.ToString()<span> </span>+ <span style="color:#a31515;">&#8221; | &#8220;</span> + Message ;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>log.WriteLine(lstrMessage);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>log.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">throw</span> ex;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">}</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal"><span style="font-size:12pt;line-height:115%;font-family:&quot;">Now Register the Plug-In for any entity on PostCreate event.It will give the AutoNuber in this format(<strong>OP/DEC08/0000000001</strong>) I.e <strong>(<span style="color:#c00000;">first two character of Entity name</span>/<span style="color:#5f497a;">three character of current month+ two digit of current year</span>/<span style="color:#00b050;">number with padding(10 digit but customizable)</span>)</strong></span></p>
<p class="MsoNormal"><strong><span style="font-size:12pt;line-height:115%;font-family:&quot;">Don’t forget to pass configuration string when registering Plug-In in Secure Configuration Field in this format</span></strong></p>
<p class="MsoNormal"><strong><span style="font-size:12pt;line-height:115%;">&lt;Config&gt;&lt;Database&gt;<span style="color:red;">Machine Name of Database</span>&lt;/Database&gt;&lt;Domain&gt;<span style="color:red;">Domain Name</span>&lt;/Domain&gt;&lt;AuthUser&gt;<span style="color:red;">Authenticated User of CRM on behalf of that query will be executed</span>&lt;/AuthUser&gt;&lt;Padding&gt;<span style="color:red;">number of character for padding</span> &lt;/Padding&gt;&lt;UniqueNumber&gt;<span style="color:red;">new_uniqueid</span>&lt;/UniqueNumber&gt;&lt;Id&gt;<span style="color:red;">new_id</span>&lt;/Id&gt;&lt;LogPath&gt; Log path as <span> </span><span style="color:red;">D:\CRM\Logs\CrmLog.txt</span>&lt;/LogPath&gt;&lt;/Config&gt;</span></strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=28&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2008/12/22/creating-autonumber-for-microsoft-dynamics-crm-40-using-plug-ins-with-the-help-of-filteredview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using FilteredView to retrieve data in Plug-In or Callout</title>
		<link>http://arvindcsit.wordpress.com/2008/12/12/using-filteredview-to-retrieve-data-in-plug-in-or-callout/</link>
		<comments>http://arvindcsit.wordpress.com/2008/12/12/using-filteredview-to-retrieve-data-in-plug-in-or-callout/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 14:07:01 +0000</pubDate>
		<dc:creator>Arvind Singh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<guid isPermaLink="false">http://arvindcsit.wordpress.com/2008/12/12/using-filteredview-to-retrieve-data-in-plug-in-or-callout/</guid>
		<description><![CDATA[To retrieve data from CRM Database( FilteredView)…..
SqlConnection connection = new SqlConnection(&#8220;DataSource=&#60;dsName&#62;;Initial Catalog=&#60;databaseName&#62; ;Integrated Security=SSPI;&#8221;);
string sqlQuery = @&#8221; select max(new_uniqueid) from FilteredView&#8221; ;
SqlCommand cmd = new SqlCommand(sqlQuery, connection);
connection.Open();
 
/// Write Logic here
 
connection.Close();
 
But this code wasn’t returning any results .It was because callout/plugin run under the context of NT Authority\Network Service.
So we need to use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=22&subd=arvindcsit&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;">To retrieve data from CRM Database( FilteredView)…..</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;color:#2b91af;">SqlConnection</span><span style="font-family:&quot;"> connection = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(<span style="color:#a31515;">&#8220;DataSource=&lt;</span>dsName&gt;<span style="color:#a31515;">;Initial Catalog=&lt;</span>databaseName&gt; <span style="color:#a31515;">;Integrated Security=SSPI;&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">string</span><span style="font-size:10pt;font-family:&quot;"> sqlQuery = <span style="color:#a31515;">@&#8221; select max(new_uniqueid) from FilteredView&#8221;</span> ;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;color:#2b91af;">SqlCommand</span><span style="font-family:&quot;"> cmd = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>(sqlQuery, connection);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;">connection.Open();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#92d050;">/// Write Logic here</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;">connection.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;"><span style="font-family:&quot;" lang="EN">But this code wasn’t returning any results .It was because callout/plugin run under the context of NT Authority\Network Service.</span></p>
<p class="MsoNormal" style="line-height:normal;"><span style="font-size:12pt;font-family:&quot;" lang="EN">So we need to use impersonation in this case, for this we can use the following code .</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;color:#2b91af;">SqlConnection</span><span style="font-family:&quot;"> connection = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(<span style="color:#a31515;">&#8220;DataSource=&lt;</span>dsName&gt;<span style="color:#a31515;">;Initial Catalog=&lt;</span>databaseName&gt; <span style="color:#a31515;">;Integrated Security=SSPI;</span></span><span style="font-size:10pt;font-family:&quot;color:#a31515;"> </span><span style="font-size:10pt;font-family:&quot;color:#00b050;">Pooling=false</span><span style="font-family:&quot;">);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">string</span><span style="font-size:10pt;font-family:&quot;"> sqlQuery = <span style="color:#a31515;">@&#8221; </span><span style="color:#00b050;">SETUSER &#8216;domainName\administrator&#8217;</span><span style="color:#a31515;"> select max(new_uniqueid) from FilteredView&#8221;</span> ;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;color:#2b91af;">SqlCommand</span><span style="font-family:&quot;"> cmd = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>(sqlQuery, connection);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;">connection.Open();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#92d050;">/// Write Logic here</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;">connection.Close();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><strong><span style="background:yellow none repeat scroll 0;font-size:12pt;font-family:&quot;" lang="EN">SETUSER</span></strong><span style="font-size:12pt;" lang="EN"> </span><span style="font-size:10pt;" lang="EN">- </span><span style="font-size:12pt;" lang="EN">To impersonate the admin who has access to the filtered views. More about SETUSER</span><span style="font-family:&quot;"></span></p>
<p class="MsoNormal" style="line-height:normal;"><span style="font-size:12pt;font-family:&quot;" lang="EN"><a href="http://msdn.microsoft.com/en-us/library/ms186297.aspx">http://msdn.microsoft.com/en-us/library/ms186297.aspx</a></span></p>
<p class="MsoNormal" style="line-height:normal;"><span style="font-size:12pt;font-family:&quot;" lang="EN">If we are not using Pooling=false in connection string its giving this error.</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:12pt;font-family:&quot;color:#c00000;">Event Log Error: The connection has been dropped because the principal that opened it subsequently assumed a new security context, and then tried to reset the connection under its impersonated security context</span><span style="font-size:12pt;font-family:&quot;">…….</span></p>
<p class="MsoNormal" style="line-height:normal;"><span style="font-size:12pt;font-family:&quot;" lang="EN"> </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arvindcsit.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arvindcsit.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arvindcsit.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arvindcsit.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arvindcsit.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arvindcsit.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arvindcsit.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arvindcsit.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arvindcsit.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arvindcsit.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arvindcsit.wordpress.com&blog=4258401&post=22&subd=arvindcsit&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://arvindcsit.wordpress.com/2008/12/12/using-filteredview-to-retrieve-data-in-plug-in-or-callout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b61a7b1a477d72d3760acf63a84745ab?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arvindcsit</media:title>
		</media:content>
	</item>
	</channel>
</rss>