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

<channel>
	<title>Mohamed Ibrahim Mostafa&#039;s Blog &#187; Mohamed Ibrahim Mostafa</title>
	<atom:link href="http://www.mohamedibrahim.net/blog/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mohamedibrahim.net/blog</link>
	<description>Technical issues, problems, errors, findings &#38; resolutions covering Microsoft Dynamics CRM, software development, Microsoft .NET, C#, VB.NET, Commerce Server, Integration, E-Commerce, Scribe, Online shops and more general technology and consultancy posts.</description>
	<lastBuildDate>Tue, 24 Aug 2010 09:22:45 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice</title>
		<link>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 13:03:48 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[CRM 4.0]]></category>
		<category><![CDATA[CRM Database]]></category>
		<category><![CDATA[CRM Service]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Entity]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=239</guid>
		<description><![CDATA[  
Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice. Custom .NET code to access CRM, create, update (edit), insert, delete, retrieve (return) and retrievemultiple records for system entities and custom entities using both entity objects and dynamic entities. 
This post is a collection of the main methods [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 10pt;"> </span> </p>
<p>Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice. Custom .NET code to access CRM, create, update (edit), insert, delete, retrieve (return) and retrievemultiple records for system entities and custom entities using both entity objects and dynamic entities. </p>
<p>This post is a collection of the main methods that you would frequently use in your .NET code (Plugin, Website) that is accessing a dynamics CRM 4.0 system and consuming its CRM services. </p>
<p>The <strong>CrmService</strong> Web service provides a set of methods used to perform the most common operations on system and custom entities. </p>
<p>This collection mainly comes from sevaral pages on MSDN. I just thought it will be useful to have them all together if we need one or more of them. </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following code shows how to set up the Web service, and how to use the <strong><span style="text-decoration: underline;">Create</span></strong><span style="text-decoration: underline;"> and <strong>Retrieve</strong></span> methods.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p><span style="font-family: Consolas; color: black; font-size: 10pt;"></p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create an account entity and assign data to some attributes.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">account newAccount = new account();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.name = "Greg Bike Store";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.accountnumber = "123456";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.address1_postalcode = "98052";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.address1_city = "Redmond";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Call the Create method to create an account.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid accountId = service.Create(newAccount);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Call the Retrieve method to retrieve an existing contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet myColumnSet = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">myColumnSet.Attributes = new string[] { "firstname" };</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact myContact = (contact) service.Retrieve ("contact", contactId, myColumnSet)</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 12pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">Create</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// You can use enums.cs from the SDK\Helpers folder to get the enumeration </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//   for Active Directory authentication.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = new contact();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the properties for the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.firstname = "Jesper";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.lastname = "Aaberg";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_line1 = "23 Market St.";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_city = "Sammamish";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_stateorprovince = "MT";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_postalcode = "99999";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.donotbulkemail = new CrmBoolean();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.donotbulkemail.Value = true;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact in Microsoft Dynamics CRM.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = service.Create(contact);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-size: small;"><span style="font-family: Calibri;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">Retrieve</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the column set object that indicates the properties to be retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet cols = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the column set.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">cols.Attributes = new string [] {"fullname"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// contactGuid is the GUID of the record being retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Retrieve the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The EntityName indicates the EntityType of the object being retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = (contact)service.Retrieve(EntityName.contact.ToString(), </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">                                             contactGuid, cols);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">RetrieveMultiple</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the ColumnSet that indicates the properties to be retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet cols = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the ColumnSet.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">cols.Attributes = new string [] {"fullname", "contactid"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the ConditionExpression.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ConditionExpression condition = new ConditionExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the condition for the retrieval to be when the </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//    contact's address' city is Sammamish.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.AttributeName = "address1_city";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.Operator = ConditionOperator.Like;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.Values = new string [] {"Sammamish"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the FilterExpression.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">FilterExpression filter = new FilterExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the filter.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">filter.FilterOperator = LogicalOperator.And;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">filter.Conditions = new ConditionExpression[] {condition};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the QueryExpression object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">QueryExpression query = new QueryExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the QueryExpression object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.EntityName = EntityName.contact.ToString();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.ColumnSet = cols;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.Criteria = filter;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Retrieve the contacts.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">BusinessEntityCollection contacts = service.RetrieveMultiple(query);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong>Update</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = new contact();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the contact object properties to be updated.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_line1 = "34 Market St.";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The contactid is a key that references the ID of the contact to be updated.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.contactid = new Key();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The contactid.Value is the GUID of the record to be changed.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.contactid.Value = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Update the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Update(contact);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong>Delete</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// contactGuid is the GUID of the record being deleted.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Delete the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The EntityName indicates the EntityType of the object being deleted.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Delete(EntityName.contact.ToString(), contactGuid);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">For Dynamic Entities: The following sample shows how to create a new entity instance by calling the <strong>CreateEntity</strong> method followed by the <strong>AddObject</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var contact = crm.CreateEntity("contact");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the string properties.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("firstname", "Allison");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("lastname", "Brown");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("emailaddress1", "<a href="mailto:allison.brown@contoso.com"><span style="color: #0000ff;">allison.brown@contoso.com</span></a>");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Setting an explicit ID value is optional, it can be left unassigned, </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//    but here it is being explicitly assigned.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var id = Guid.NewGuid();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("contactid", id);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Pass the entity name of the entity being created as the first parameter.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">crm.AddObject("contact", contact);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">crm.SaveChanges();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The ID value can be retrieved after you have called the SaveChanges method.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var id2 = contact.GetPropertyValue&lt;Guid&gt;("contactid");</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 10pt;">These methods have been collected from MSDN mainly from these two locations:  <a href="http://msdn.microsoft.com/en-us/library/cc151016.aspx"><span style="color: #1f497d;">http://msdn.microsoft.com/en-us/library/cc151016.aspx</span></a> and <a href="http://msdn.microsoft.com/en-us/library/ff681571.aspx"><span style="color: #1f497d;">http://msdn.microsoft.com/en-us/library/ff681571.aspx</span></a> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Current User Security Roles in Microsoft Dynamics CRM 4.0 on client side using JavaScript calls to CRM Service &amp; API</title>
		<link>http://www.mohamedibrahim.net/blog/2010/07/27/get-current-user-security-roles-in-microsoft-dynamics-crm-4-0-on-client-side-using-javascript-calls-to-crm-service-api/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/07/27/get-current-user-security-roles-in-microsoft-dynamics-crm-4-0-on-client-side-using-javascript-calls-to-crm-service-api/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 15:18:16 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[CRM Service]]></category>
		<category><![CDATA[Dynamics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Service Call]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=247</guid>
		<description><![CDATA[In Microsoft Dynamics CRM 4.0, it is quite common that you want to call the CRM service from client side: i.e. Call the CRM service using JavaScript code that is located on the OnLoad, OnSave or OnChange events on a Dynamics CRM entity or field event.
The most common call is the call to CRM service to [...]]]></description>
			<content:encoded><![CDATA[<p>In Microsoft Dynamics CRM 4.0, it is quite common that you want to call the CRM service from client side: i.e. Call the CRM service using JavaScript code that is located on the OnLoad, OnSave or OnChange events on a Dynamics CRM entity or field event.</p>
<p>The most common call is the call to CRM service to determine what roles the current user has.</p>
<p>The following function returns all roles of a specific user by creating a SOAP message request to the CRM Service:</p>
<pre>//*********************
function GetCurrentUserRoles()
{
 var xml = "" +
 "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;" +
 "&lt;soap:Envelope xmlns:soap=\"<a href="http://schemas.xmlsoap.org/soap/envelope/\">http://schemas.xmlsoap.org/soap/envelope/\</a>" " +
 " xmlns:xsi=\"<a href="http://www.w3.org/2001/XMLSchema-instance\">http://www.w3.org/2001/XMLSchema-instance\</a>" xmlns:xsd=\"<a href="http://www.w3.org/2001/XMLSchema\">http://www.w3.org/2001/XMLSchema\</a>"&gt;" +
 GenerateAuthenticationHeader() +
 " &lt;soap:Body&gt;" +
 " &lt;RetrieveMultiple xmlns=\"<a href="http://schemas.microsoft.com/crm/2007/WebServices\">http://schemas.microsoft.com/crm/2007/WebServices\</a>"&gt;" +
 " &lt;query xmlns:q1=\"<a href="http://schemas.microsoft.com/crm/2006/Query\">http://schemas.microsoft.com/crm/2006/Query\</a>" xsi:type=\"q1:QueryExpression\"&gt;" +
 " &lt;q1:EntityName&gt;role&lt;/q1:EntityName&gt;" +
 " &lt;q1:ColumnSet xsi:type=\"q1:ColumnSet\"&gt;" +
 " &lt;q1:Attributes&gt;" +
 " &lt;q1:Attribute&gt;name&lt;/q1:Attribute&gt;" +
 " &lt;/q1:Attributes&gt;" +
 " &lt;/q1:ColumnSet&gt;" +
 " &lt;q1:Distinct&gt;false&lt;/q1:Distinct&gt;" +
 " &lt;q1:LinkEntities&gt;" +
 " &lt;q1:LinkEntity&gt;" +
 " &lt;q1:LinkFromAttributeName&gt;roleid&lt;/q1:LinkFromAttributeName&gt;" +
 " &lt;q1:LinkFromEntityName&gt;role&lt;/q1:LinkFromEntityName&gt;" +
 " &lt;q1:LinkToEntityName&gt;systemuserroles&lt;/q1:LinkToEntityName&gt;" +
 " &lt;q1:LinkToAttributeName&gt;roleid&lt;/q1:LinkToAttributeName&gt;" +
 " &lt;q1:JoinOperator&gt;Inner&lt;/q1:JoinOperator&gt;" +
 " &lt;q1:LinkEntities&gt;" +
 " &lt;q1:LinkEntity&gt;" +
 " &lt;q1:LinkFromAttributeName&gt;systemuserid&lt;/q1:LinkFromAttributeName&gt;" +
 " &lt;q1:LinkFromEntityName&gt;systemuserroles&lt;/q1:LinkFromEntityName&gt;" +
 " &lt;q1:LinkToEntityName&gt;systemuser&lt;/q1:LinkToEntityName&gt;" +
 " &lt;q1:LinkToAttributeName&gt;systemuserid&lt;/q1:LinkToAttributeName&gt;" +
 " &lt;q1:JoinOperator&gt;Inner&lt;/q1:JoinOperator&gt;" +
 " &lt;q1:LinkCriteria&gt;" +
 " &lt;q1:FilterOperator&gt;And&lt;/q1:FilterOperator&gt;" +
 " &lt;q1:Conditions&gt;" +
 " &lt;q1:Condition&gt;" +
 " &lt;q1:AttributeName&gt;systemuserid&lt;/q1:AttributeName&gt;" +
 " &lt;q1:Operator&gt;EqualUserId&lt;/q1:Operator&gt;" +
 " &lt;/q1:Condition&gt;" +
 " &lt;/q1:Conditions&gt;" +
 " &lt;/q1:LinkCriteria&gt;" +
 " &lt;/q1:LinkEntity&gt;" +
 " &lt;/q1:LinkEntities&gt;" +
 " &lt;/q1:LinkEntity&gt;" +
 " &lt;/q1:LinkEntities&gt;" +
 " &lt;/query&gt;" +
 " &lt;/RetrieveMultiple&gt;" +
 " &lt;/soap:Body&gt;" +
 "&lt;/soap:Envelope&gt;" +
 "";

 var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
 xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
 xmlHttpRequest.setRequestHeader("SOAPAction"," <a href="http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple">http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple</a>");
 xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
 xmlHttpRequest.send(xml);

 var resultXml = xmlHttpRequest.responseXML;
 return(resultXml);
}
//*********************</pre>
<p> The following function checks if the specified user has a specified user role:</p>
<pre>//*********************
function UserHasRole(roleName) {
    //get Current User Roles, oXml is an object
    var oXml = GetCurrentUserRoles();
    if (oXml != null) {
        //select the node text
        var roles = oXml.selectNodes("//BusinessEntity/q1:name");
        if (roles != null) {
            for (i = 0; i &lt; roles.length; i++) {
                if (roles[i].text == roleName) {
                    //return true if user has this role
                    return true;
                }
            }
        }
    }
    //otherwise return false
    return false;
}
//*********************</pre>
<p>The following code block uses the above function to do some logic based on user&#8217;s security roles:</p>
<pre>if(UserHasRole("System Administrator"))
{
  //do something
}
else
{
   //do something else
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/07/27/get-current-user-security-roles-in-microsoft-dynamics-crm-4-0-on-client-side-using-javascript-calls-to-crm-service-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding ISV web applications in Microsoft Dynamics CRM 4.0 through SiteMap (not as an IFrame) via a left navigation link. Application &amp; link Access restriction through Site Map</title>
		<link>http://www.mohamedibrahim.net/blog/2010/06/14/embedding-isv-web-applications-in-microsoft-dynamics-crm-4-0-through-sitemap-not-as-an-iframe-via-a-left-navigation-link-application-link-access-restriction-through-site-map/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/06/14/embedding-isv-web-applications-in-microsoft-dynamics-crm-4-0-through-sitemap-not-as-an-iframe-via-a-left-navigation-link-application-link-access-restriction-through-site-map/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 18:12:40 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[ISV]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sitemap]]></category>
		<category><![CDATA[Web Application]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=252</guid>
		<description><![CDATA[There are (at least) two standard ways of implementing an external ISV web application (website, html, .NET, etc..) inside your dynamics CRM application.
The first way is by creating an IFrame inside the form of an entity. This is quite straight forward and can be achieved from the entity customisation section in CRM settings.
The second option is [...]]]></description>
			<content:encoded><![CDATA[<p>There are (at least) two standard ways of implementing an external ISV web application (website, html, .NET, etc..) inside your dynamics CRM application.</p>
<p>The first way is by creating an IFrame inside the form of an entity. This is quite straight forward and can be achieved from the entity customisation section in CRM settings.</p>
<p>The second option is to create a link in the left navigation of your Microsoft Dynamics CRM 4.0 solution. This link can then point to your ISV webpage (aspx page for example) and you will have your web page implemented and embedded inside CRM. If you also do the application css (stylesheet file)  to be same colours and similar styles as CRM colours and styles, your application will be presented nicely inside CRM as if it is part of CRM. The permission and restriction of access to this web application and its left navigation link is also controlled to show/hide the applications to users.</p>
<p>This post is discussing the second option.</p>
<p>Embedding a webpage or web application in CRM and having  CRM&#8217;s left navigation linked to it can be done by editing the sitemap customisation file (xml). This left nav link can be shown or hidden to users based on their security roles and this is also controlled in the site map file. If the link is hidden, then obviously the web application will not be accessible and cannot be retrieved by unauthorised users.</p>
<p>The following is an example of a sitemap file that displays two links to two applications on the top of the left navigation menu of CRM 4.0. The privilage for accessing each link is also set in the following example:</p>
<pre>&lt;SiteMap&gt;
    &lt;SiteMap&gt;
      &lt;Area Id="Workplace" ResourceId="Area_Workplace" ShowGroups="true"
Icon="/_imgs/workplace_24x24.gif" DescriptionResourceId="Workplace_Description"&gt;
        &lt;Group Id="MyWork" ResourceId="Group_MyWork"
DescriptionResourceId="My_Work_Description"&gt;
          &lt;SubArea Id="MyWebApplication" Icon="/_imgs/ico_18_servicecal.gif"
Url="../../ISV/MyWebApplication/WebPage.aspx" AvailableOffline="false"&gt;
            &lt;Titles&gt;
              &lt;Title LCID="1033" Title="My Web Application ONE" /&gt;
            &lt;/Titles&gt;
            &lt;Descriptions&gt;
              &lt;Description LCID="1033" Description="My Web Application ONE" /&gt;
            &lt;/Descriptions&gt;
&lt;!-- this is where you control displaying the 1st link--&gt;
&lt;!-- if the user has read and write access to entity Kbarticle (for ex)--&gt;
&lt;!-- then they should be able to view this link. Otherwise, its hidden--&gt;
            &lt;Privilege Entity="kbarticle" Privilege="Read,Write" /&gt;
          &lt;/SubArea&gt;&lt;!--another example follows: --&gt;
          &lt;SubArea Id="WebPage2" Icon="/_imgs/ico_18_servicecal.gif"  
Url="../../ISV/WebApplication2/index.htm" AvailableOffline="false"&gt;
            &lt;Titles&gt;
              &lt;Title LCID="1033" Title="Web Page 2" /&gt;
            &lt;/Titles&gt;
            &lt;Descriptions&gt; 
&lt;!-- if the user has create access to entity Kbarticle (for ex)--&gt;
&lt;!-- then they should be able to view this link. Otherwise, its hidden--&gt;
              &lt;Description LCID="1033" Description="Web Page 2" /&gt;
            &lt;/Descriptions&gt;
            &lt;Privilege Entity="kbarticle" Privilege="Create" /&gt;
          &lt;/SubArea&gt;
&lt;!-- The following is the standard activity left link for CRM--&gt;
          &lt;SubArea Id="nav_activities" Entity="activitypointer"  
DescriptionResourceId="Activities_SubArea_Description"  
Url="/Workplace/home_activities.aspx" /&gt;</pre>
<p>This is how you can get site map to control your left navigation buttons and get them to link to ISV applications. Please mind that you might need to change the relative location of your application in the URL parameter.</p>
<p>Hope this helps.</p>
<pre> </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/06/14/embedding-isv-web-applications-in-microsoft-dynamics-crm-4-0-through-sitemap-not-as-an-iframe-via-a-left-navigation-link-application-link-access-restriction-through-site-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s new in Microsoft Dynamics CRM 5 &#8211; Microsoft Dynamics CRM 5 Release date &#8211; Introduction and Early look at Dynamics CRM 5</title>
		<link>http://www.mohamedibrahim.net/blog/2010/05/19/whats-new-in-microsoft-dynamics-crm-5-microsoft-dynamics-crm-5-release-date-introduction-and-early-look-at-dynamics-crm-5/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/05/19/whats-new-in-microsoft-dynamics-crm-5-microsoft-dynamics-crm-5-release-date-introduction-and-early-look-at-dynamics-crm-5/#comments</comments>
		<pubDate>Wed, 19 May 2010 11:53:08 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM 5]]></category>
		<category><![CDATA[Dynamics CRM 5]]></category>
		<category><![CDATA[Microsoft Dynamics CRM 5]]></category>
		<category><![CDATA[New Release]]></category>
		<category><![CDATA[Release Date]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=211</guid>
		<description><![CDATA[I promised that I will be updating this post everytime there is new information about CRM 5 (now called CRM 2011).
Here is an screenshot (image) of the new CRM 2011 Dashboards which are expected to be the best new feature in 2011:

Source: http://blogs.msdn.com/b/ukcrm/archive/2010/07/12/crm-5-becomes-crm-2011.aspx
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
These are some questions that many people are asking about Microsoft Dynamic CRM 5.
I know [...]]]></description>
			<content:encoded><![CDATA[<p>I promised that I will be updating this post everytime there is new information about CRM 5 (now called CRM 2011).</p>
<p>Here is an screenshot (image) of the new CRM 2011 Dashboards which are expected to be the best new feature in 2011:</p>
<p><a href="http://www.mohamedibrahim.net/blog/wp-content/uploads/2010/05/CRM2011Dashboards.jpg"><img class="alignnone size-full wp-image-262" title="CRM2011Dashboards" src="http://www.mohamedibrahim.net/blog/wp-content/uploads/2010/05/CRM2011Dashboards.jpg" alt="" width="750" height="470" /></a><a href="http://www.mohamedibrahim.net/blog/wp-content/uploads/2010/05/CRM2011Dashboards.jpg"></a></p>
<p>Source: <a href="http://blogs.msdn.com/b/ukcrm/archive/2010/07/12/crm-5-becomes-crm-2011.aspx">http://blogs.msdn.com/b/ukcrm/archive/2010/07/12/crm-5-becomes-crm-2011.aspx</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>These are some questions that many people are asking about Microsoft Dynamic CRM 5.</p>
<p>I know my answers below will not satisfy everybody but I promise, once we are allowed to do so, and I&#8217;m relieved from my NDA, I Will post <strong>all information about all new features in Microsoft Dynamics CRM 5 with screenshots, show cases and demo of the product </strong>- so watch this space. This will hopefully happen when the beta version is released.</p>
<p>Now to the Questions:</p>
<p>* What are the new features and functionality and What&#8217;s new in Microsoft Dynamics CRM 5?</p>
<p>* Microsoft Dynamics CRM 5 Release date &#8211; When will it be released for production or the beta release?</p>
<p> This is what Microsoft has recently announced:</p>
<ul>
<li>The upcoming release will be named Microsoft Dynamics CRM 2011.</li>
<li>Beta will be publicly available in September 2010. You can sign up to be notified of availability of BETA at <a href="http://crm.dynamics.com/crm2011beta" target="_blank">http://crm.dynamics.com/crm2011beta</a>.</li>
<li>CRM Online International Expansion reaches 40 planned markets and 41 languages when it is launched.</li>
<li>Microsoft Dynamics Marketplace expected to launch for CRM solutions in September 2010.</li>
</ul>
<p>* Can we have an early look or introduction to Microsoft Dynamics CRM 5 changes and new features:</p>
<p>I am still covered by Microsoft&#8217;s NDA which prevents me from revealing anything not already made public by Microsoft. Please find below links to some information on Microsoft Dynamics CRM 5 from what Microsoft has made public :</p>
<p>· <a href="http://blogs.msdn.com/b/crm/archive/2010/07/12/introducing-microsoft-dynamics-crm-2011.aspx">http://blogs.msdn.com/b/crm/archive/2010/07/12/introducing-microsoft-dynamics-crm-2011.aspx</a> </p>
<p>· <a href="http://blogs.msdn.com/crm/archive/2008/12/18/an-early-look-at-crm-5.aspx">http://blogs.msdn.com/crm/archive/2008/12/18/an-early-look-at-crm-5.aspx</a></p>
<p>· <a href="http://blogs.msdn.com/girishr/archive/2009/11/21/pdc-phone-company-crm-azure-demo.aspx">http://blogs.msdn.com/girishr/archive/2009/11/21/pdc-phone-company-crm-azure-demo.aspx</a></p>
<p>· <a href="http://microsoftpdc.com/Sessions/PR31">http://microsoftpdc.com/Sessions/PR31</a></p>
<p>· <a href=" http://microsoftpdc.com/Sessions/P09-07">http://microsoftpdc.com/Sessions/P09-07</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/05/19/whats-new-in-microsoft-dynamics-crm-5-microsoft-dynamics-crm-5-release-date-introduction-and-early-look-at-dynamics-crm-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft Dynamics CRM 4 field level validation using javascript regular expression on client side handling the onChange event to validate and check the value and text of a CRM 4.0 field</title>
		<link>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 01:21:41 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Dynamics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=184</guid>
		<description><![CDATA[Please note that this post is aimed as showing how to use javascript regular expression field level validation in Microsoft Dynamics CRM. The post does not focus on the many ways of getting a regular expression. The example regular expression below is used for explanation only.
If you want to create validation at field level in [...]]]></description>
			<content:encoded><![CDATA[<p>Please note that this post is aimed as showing how to use javascript regular expression field level validation in Microsoft Dynamics CRM. The post does not focus on the many ways of getting a regular expression. The example regular expression below is used for explanation only.</p>
<p>If you want to create validation at field level in Microsoft Dynamics CRM 4 to check the input value and text of a CRM field in an entity form, you can do this using regular expressions written in javascript code that handles the on change (onChange) event of this field at client side.</p>
<p>Below is an example of a regular expression but you might want to use your own regex value or search online for almost unlimited number of regular expressions that do just about anything.</p>
<p>For example, if you want to validate a CRM 4 field so that only a 4 digit year value starting from year 1980 is entered in the field text box, follow the following steps:</p>
<p>- Open the entity customisation form<br />
- select the field you want to validate using javascript regular expression.<br />
- Click on field properties, events tab and then open the onChange event.<br />
- In the onChange event type the following javascript code (script) to handle the event and implement the field level validation:</p>
<pre>//-----------------------------
//Regular expression ensuring a 4 digit year value is input starting from year 1980.
var reDate =/^(([1]{1}[9]{1}[8-9]{1}\d{1})|([2-9]{1}\d{3}))$/</pre>
<pre>//Check if the input value satisfies the regular expression condition
if (document.crmForm.all.new_yearfieldname.value.search(reDate)==-1)
{//if match failed
alert("Please enter a valid year value. Year value must be four digits starting from the year 1980")
crmForm.all.new_yearfieldname.value = '';
}
//-----------------</pre>
<p>Another way of doing this is as follows;</p>
<pre><span style="font-family: Georgia;">//-----------------------------
var regexS = "^(([1]{1}[9]{1}[8-9]{1}\d{1})|([2-9]{1}\d{3}))$"; 
var regex = new RegExp( regexS ); 
var results = regex.exec( crmForm.all.new_yearfieldname.value);
if( results == null )   
{//if match failed
alert("Please enter a valid year value. Year value must be four digits starting from the year 1980")
crmForm.all.new_yearfieldname.value = '';
}
//-----------------------------</span></pre>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax Update progress screen to block access to form during background server side processes</title>
		<link>http://www.mohamedibrahim.net/blog/2010/04/04/189/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/04/04/189/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 01:38:21 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=189</guid>
		<description><![CDATA[If you are writing an Ajax based .NET web application or web page, there are situations were you might want to block the whole webpage from being accessed while a background or server side process is taking place. So for example if the user clicks submit, you want to make the web page not accessible [...]]]></description>
			<content:encoded><![CDATA[<p>If you are writing an Ajax based .NET web application or web page, there are situations were you might want to block the whole webpage from being accessed while a background or server side process is taking place. So for example if the user clicks submit, you want to make the web page not accessible until the backend server side event handler function finishes and reloads the page.</p>
<p>To do this, you need to do the following:</p>
<p>In the button click event, call the javascript function showprogress (client side &#8211; aspx page code):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<pre>&lt;asp:Button ID="ApplyFilterButton" runat="server" OnClick="ApplyFilterButton_Click"
OnClientClick="if(Page_ClientValidate())ShowProgress();" Text="Apply Filter"
CssClass="ms-crm-Button" Style="height: 23px" /&gt;</pre>
<p>The show progress function should look something like the following:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<pre>&lt;script type="text/javascript"&gt;
   function ShowProgress() {
document.getElementById('&lt;% Response.Write(PageUpdateProgress.ClientID); %&gt;').style.display = "inline";
        }
&lt;/script&gt;</pre>
<p> The update progress control should look something like this:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<pre>&lt;asp:UpdateProgress ID="PageUpdateProgress" runat="server"
AssociatedUpdatePanelID="PageHiddenPanel" DisplayAfter="50"&gt;
  &lt;ProgressTemplate&gt;
     &lt;div id="progressDiv"
     style="background-position: center center;
     background-image: url(../../Images/progress.gif);
     background-repeat: no-repeat; background-attachment: fixed;
     vertical-align: middle; background-color: #000;
     filter: alpha(opacity=50);"&gt;
            &lt;/div&gt;
            &lt;script type="text/javascript"&gt;
                var targetDiv = document.getElementById("progressDiv");
                targetDiv.style.top = 0;
                targetDiv.style.left = 0;
                targetDiv.style.height = screen.availHeight;
                targetDiv.style.width = screen.availWidth;
            &lt;/script&gt;
        &lt;/ProgressTemplate&gt;
    &lt;/asp:UpdateProgres&gt; </pre>
<p> Hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/04/04/189/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Click through to CRM records from SSRS custom report for Microsfot Dynamics CRM 4. Linking information on SQL Reporting Services custom CRM reports to Dynamics CRM 4 records and opening them up from within the report.</title>
		<link>http://www.mohamedibrahim.net/blog/2010/03/17/click-through-to-crm-records-from-ssrs-custom-report-for-microsfot-dynamics-crm-4-linking-information-on-sql-reporting-services-custom-crm-reports-to-dynamics-crm-4-records-and-opening-them-up-from-w/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/03/17/click-through-to-crm-records-from-ssrs-custom-report-for-microsfot-dynamics-crm-4-linking-information-on-sql-reporting-services-custom-crm-reports-to-dynamics-crm-4-records-and-opening-them-up-from-w/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 18:19:34 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Expression]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Report Server]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQL query]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=174</guid>
		<description><![CDATA[Click through to CRM records from SSRS custom report for Microsfot Dynamics CRM 4. Linking information on SQL Reporting Services custom CRM reports to Dynamics CRM 4 records and opening them up from within the report.]]></description>
			<content:encoded><![CDATA[<p>If you are writing a custom report &#8211; SQL Server Reporting Services (SSRS) report for Microsoft Dynamics CRM 4, you might want to add the functionality (sql expression) to click through to a record. This can be applied to some or all information shown on the report, so that if you click on the information text box, you open up the corresponding CRM record in a new window such as: click on sub-account in the sub-accounts list to open this sub-account CRM record, or the same for contact, opportunities and so on.</p>
<p>To do this, right click on the text box in where you will be putting the expression and the value to be clicked on, and click on Texbox properties. On there click on Actions on the left, select last option &#8220;Go to URL&#8221; and in the expression box type the following query expression</p>
<pre>=IIF(IsNothing(Parameters!CRM_URL.Value),system.dbnull.value,Parameters!CRM_URL.Value &amp; "?ID={"&amp;Fields!Accountid.Value.ToString()&amp;"}&amp;OTC=1")
/*Replace "&amp;Fields!Accountid" with the ID of the corresponding record */
/*you want to be open, so contactid, opportunityid or any other custom entity id field*/
/*Also replace OTC value above with the Entity Object type Code (OTC) value*/</pre>
<p>You can get any entities OTC value from the &#8220;EntityView&#8221; view or for the full list of all system entities type codes, read this MSDN article: <a href="http://msdn.microsoft.com/en-us/library/bb887791.aspx">http://msdn.microsoft.com/en-us/library/bb887791.aspx</a>. Obviously you will need to get the OTC value for your custom entities from the &#8220;EntityView&#8221; view from your Dynamics CRM database. You can use a query similar to the following:</p>
<pre>select entitytypecode from entityview where entityname = 'account'</pre>
<p>This sql expression can work with any entity either system (cusomisable) or custom entity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/03/17/click-through-to-crm-records-from-ssrs-custom-report-for-microsfot-dynamics-crm-4-linking-information-on-sql-reporting-services-custom-crm-reports-to-dynamics-crm-4-records-and-opening-them-up-from-w/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hide tab in any entity form in Microsoft Dynamics CRM 4 using Javascript in onLoad event of the form.</title>
		<link>http://www.mohamedibrahim.net/blog/2010/03/03/hide-tab-in-any-entity-form-in-microsoft-dynamics-crm-4-using-javascript-in-onload-event-of-the-form/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/03/03/hide-tab-in-any-entity-form-in-microsoft-dynamics-crm-4-using-javascript-in-onload-event-of-the-form/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 20:03:41 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Custom Entity]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=177</guid>
		<description><![CDATA[Hide tab in any entity form in Microsoft Dynamics CRM 4 using Javascript in onLoad event of the form.]]></description>
			<content:encoded><![CDATA[<p>In many cases, you might want to remove one of the tabs of an entity form in Microsoft Dynamics CRM 4. This can be specifically helpful in two cases:</p>
<p>1- If you want to hide and show tabs depending on a picklist value selection such as contact type: Hide Work details if contact is of type internal contact for example</p>
<p>2- If you want to hide the Administration and Notes tab from an entity form while these tabs are locked and cannot be removed from the entity form.</p>
<p>To hide a tab in an entity form, you can use the following Javascript sample script:</p>
<pre>//---------------------------Hide a tab by passing tab name to the function
HideTab('Administration');
//replace "Administration" with your tab name</pre>
<pre>function HideTab (tabText)
{
 var tab = FindTab(tabText);
 if (tab)
 {
  tab.style.display = "none";
 }
}
function FindTab(tabText)
{
 var tabBar = document.getElementById("crmTabBar");
 if (tabBar)
 {
  var tabs = tabBar.childNodes;  

  for (var i = 0, len = tabs.length; i &lt; len; i++)
  {
   var currentTab = tabs[i];
   if (currentTab.innerText === tabText)
   {
    return currentTab;
   }
  }
 }
}
//-----------------end of script--------</pre>
<p>Maxjerin has added a new code suggestion. Maxjerin&#8217;s code hides a tab based on the onChange event of a field on the form. If the primary contact &#8220;name&#8221; field is maxjerin, the tab is displayed. Otherwise the tab is hidden.</p>
<p>I have updated the post to include Maxjerin&#8217;s code &#8211; Thanks Maxjerin:</p>
<p>Here is the code that I used to HIDE/UNHIDE a tab when I wanted to show it for only one particular user and hide for others. The code includes some alert messages just for debugging purpose which you might find useful to understand the code. You may remove them once done.</p>
<p>This section goes into the onChange section of the Primary Contact lookup field</p>
<pre>if (crmForm.all.primarycontactid.DataValue == null )
{
var strTabStatus = TabStatus(‘Profile’);
if ( strTabStatus == ”)
{
alert(“Primary Contact none, hiding the tab”);
HideTab(‘Profile’);
}
}
else if (crmForm.all.primarycontactid.DataValue[0].name == ‘maxjerin’)
{
alert(“Primary Contact p f, unhiding the tab”);
UnHideTab(‘Profile’);
//replace “Administration” with your tab name
}
else if (crmForm.all.primarycontactid.DataValue[0].name != ‘maxjerin’)
{
var strTabStatus = TabStatus(‘Profile’);
if (strTabStatus == ” )
{
alert(“Primary Contact other than maxjerin, Hiding the tab”);
HideTab(‘Profile’);
}
}</pre>
<pre>function HideTab (tabText)
{
var tab = FindTab(tabText);
if (tab)
{
tab.style.display = “none”;
}
}</pre>
<pre>function UnHideTab (tabText)
{
var tab = FindTab(tabText);
if (tab)
{
tab.style.display = “”;
}
}</pre>
<pre>function FindTab(tabText)
{
var tabBar = document.getElementById(“crmTabBar”);
if (tabBar)
{
var tabs = tabBar.childNodes;</pre>
<pre>for (var i = 0, len = tabs.length; i &lt; len; i++)
{
var currentTab = tabs[i];
if (currentTab.innerText === tabText)
{
return currentTab;
}
}
}
}</pre>
<pre>function TabStatus(tabText)
{
var tabBar = document.getElementById(“crmTabBar”);
if (tabBar)
{
var tabs = tabBar.childNodes;</pre>
<pre>for (var i = 0, len = tabs.length; i &lt; len; i++)
{
var currentTab = tabs[i];
if (currentTab.innerText === tabText)
{
if (currentTab.style.display == ‘none’)
{
alert(“tab already hidden, TAB NAME: ” + currentTab.innerText );
return “none”;
}
else
{
alert(“tab is visible, TAB NAME: ” + currentTab.innerText );
return “”;
}
}
}
}
}</pre>
<pre>//-----------------------------------------------------------------------</pre>
<pre>Please comment below if you have any feedback or anything to add.</pre>
<pre>Thanks</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/03/03/hide-tab-in-any-entity-form-in-microsoft-dynamics-crm-4-using-javascript-in-onload-event-of-the-form/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Return and display picklist value (display value) in custom sql report  reporting services report in Microsoft Dynamics CRM 4 entity attribute and StringMap picklist values table</title>
		<link>http://www.mohamedibrahim.net/blog/2010/02/24/return-and-display-picklist-value-display-value-in-custom-sql-report-reporting-services-report-in-microsoft-dynamics-crm-4-entity-attribute-and-stringmap-picklist-values-table/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/02/24/return-and-display-picklist-value-display-value-in-custom-sql-report-reporting-services-report-in-microsoft-dynamics-crm-4-entity-attribute-and-stringmap-picklist-values-table/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 17:56:31 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Queries]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=172</guid>
		<description><![CDATA[Normally, you should be able to get the picklist display value and picklist item id in the filtered view of any entity. In some cases, you may need to work with StringMap table directly to get the picklist values for a specific field of a given entity. This could be the case if you are [...]]]></description>
			<content:encoded><![CDATA[<p>Normally, you should be able to get the picklist display value and picklist item id in the filtered view of any entity. In some cases, you may need to work with StringMap table directly to get the picklist values for a specific field of a given entity. This could be the case if you are not using the filtered view for some reason or if you want to write a report based on the table or the non-filtered view, the following post is providng the query (queries) needed to do so.</p>
<p>To get the display value of any picklist, you need to use the StringMap table. If you are writing a custom ssrs (SQL Server Reporting Services) report for Dynamics CRM 4, you usually need to return the picklist display value not the picklist item id.</p>
<p>For example: in the opportunity entity, you have a picklist attribute &#8220;Rating&#8221; (attribute name opportunityratingcode). If you are writing a custom SQL report to add to CRM and you want to display the values of the attribute, you will find that the display value of the picklist is not stored in the filtered view of Opportunity (FilteredOpportunity). To get the display value of any picklist, you need to use the StringMap table.</p>
<p>There many ways to get the information from the StringMap table, I will mention two ways here:</p>
<pre>1) using Inner Join (simple - one picklist only)
This way, you just simply join the two tables: your entity filteredview and the StringMap table
/* the query uses out of the box attributes, so should run successfully on all CRM organisations*/
SELECT opp.name, opp.estimatedvalue_base, opp.closeprobability, StringMap.Value
FROM Opportunity as Opp INNER JOIN
  StringMap ON Opp.opportunityratingcode = StringMap.AttributeValue
WHERE (StringMap.ObjectTypeCode = 3) AND (StringMap.AttributeName = N'opportunityratingcode')
AND (opp.accountid = 'input your accoung GUID here'</pre>
<p>This query will return list of all Opportunities for the specified account display the picklist display value rather than the id.</p>
<p>2) using Temp table (my prefered way for multiple picklists)</p>
<p>This query is longer and uses/declares temp tables but it is the simplest way in case you have several picklists and you want to return the display value of multiple picklists. You just create several temp tables just like @TempSM, where each temp table returns the list of display values for each picklist and then join them together.</p>
<pre>1 Picklist query:
/* the query uses out of the box attributes, so should run successfully on all CRM organisations*/
Declare @TempOpp table(OpportunityID uniqueidentifier, OpportunityName nVarchar(max),
Estimatedvalue float, Probability float, Rating nVarchar(max))
Insert into @TempOpp
select opp.opportunityid,opp.name ,
opp.estimatedvalue_base,
opp.closeprobability,
opp.OpportunityRatingCode
From Opportunity opp
where opp.accountid = '97F97A5A-2622-DF11-A1C3-005056BA6B8A'
Declare @TempSM table(AttributeValue nVarchar(max), Value nVarchar(max))
Insert into @TempSM
select AttributeValue, Value
from StringMap
WHERE (StringMap.ObjectTypeCode = 3) AND
(StringMap.AttributeName = N'opportunityratingcode' )
select t1.OpportunityName, t1.Estimatedvalue, t1.Probability, t2.Value as RatingDisplayValue
from @TempOpp as t1 left outer JOIN @TempSM as t2 ON
(t1.Rating = t2.AttributeValue)</pre>
<p>This query will return list of all Opportunities for the specified account display the picklist display value rather than the id.</p>
<pre>2 Picklists query:
------------------
/* the query uses out of the box attributes, so should run successfully on all CRM organisations*/
Declare @TempOpp1 table(OpportunityID uniqueidentifier, OpportunityName nVarchar(max),
Estimatedvalue float, Probability float, Rating nVarchar(max), Priority nVarchar(max))
Insert into @TempOpp1
select opp.opportunityid,opp.name ,
opp.estimatedvalue_base,
opp.closeprobability,
opp.OpportunityRatingCode,
opp.PriorityCode
From Opportunity opp
where opp.accountid = '97F97A5A-2622-DF11-A1C3-005056BA6B8A'
/* Now we have @TempOpp1 with list of all opportunities for the specified account but with ID for picklist value not display names*/
/*Then we declare a temp table for Rating picklist*/
Declare @TempSM table(AttributeValue nVarchar(max), Value nVarchar(max))
Insert into @TempSM
select AttributeValue, Value
from StringMap
WHERE (StringMap.ObjectTypeCode = 3) AND
(StringMap.AttributeName = N'opportunityratingcode' )
Declare @TempOpp2 table(OpportunityID uniqueidentifier, OpportunityName nVarchar(max),
Estimatedvalue float, Probability float, Rating nVarchar(max), Priority nVarchar(max))
Insert into @TempOpp2
select t1.OpportunityID, t1.OpportunityName, t1.Estimatedvalue, t1.Probability,
t2.Value as RatingDisplayValue,t1.Priority as Priority
from @TempOpp1 as t1 left outer JOIN @TempSM as t2 ON
(t1.Rating = t2.AttributeValue)
/*tempopp2 now has opportunities with the rating display value*/
/*Now creating a temp table for Priority picklist*/
Declare @TempSM1 table(AttributeValue nVarchar(max), Value nVarchar(max))
Insert into @TempSM1
select AttributeValue, Value
from StringMap
WHERE (StringMap.ObjectTypeCode = 3) AND
(StringMap.AttributeName = N'PriorityCode' )
select t1.OpportunityID, t1.OpportunityName, t1.Estimatedvalue, t1.Probability,
t1.Rating as RatingDisplayValue,t2.Value as Priority
from @TempOpp2 as t1 left outer JOIN @TempSM1 as t2 ON
(t1.Rating = t2.AttributeValue)

--------------------------------------------</pre>
<p>and so on. You create temp table for each picklist, join it with opportunity temp table and then carry on.</p>
<p>Note: This is one way of doing this. There are obviously many other shorter ways of doing this. I personally prefer temp tables a lot because although longer, they are simpler and easier to use. They also bypass any issues with null values in the right table of the join.</p>
<p>Not related Note: Always use filtered views when writing custom SQL reports on SSRS for CRM as they comply with CRM security.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/02/24/return-and-display-picklist-value-display-value-in-custom-sql-report-reporting-services-report-in-microsoft-dynamics-crm-4-entity-attribute-and-stringmap-picklist-values-table/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hide, Display, Resize and Rename left navigation links, CRM fields and attributes using Javascript for Microsoft Dyanmics CRM 4.</title>
		<link>http://www.mohamedibrahim.net/blog/2010/02/17/hide-display-resize-and-rename-left-navigation-links-crm-fields-and-attributes-using-javascript-for-microsoft-dyanmics-crm-4/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/02/17/hide-display-resize-and-rename-left-navigation-links-crm-fields-and-attributes-using-javascript-for-microsoft-dyanmics-crm-4/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 18:00:32 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Custom Entity]]></category>
		<category><![CDATA[Field]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=164</guid>
		<description><![CDATA[Scripts for Resizing, Hiding and renaming left navigation links, fields and attributes in Microsoft Dynamics CRM 4 using Javascript.]]></description>
			<content:encoded><![CDATA[<p>Scripts for Resizing, Hiding and renaming left navigation links, fields and attributes in Microsoft Dynamics CRM 4 using Javascript. This post is just a collection of some Javascript code for various common scripts that is frequently used in CRM form events, CRM entity events, etc. These script blocks can be used in OnLoad, OnSave events for CRM forms and OnChange events for CRM fields.</p>
<pre>//------- Resize CRM form in the onload event
window.resizeTo(screen.availWidth * 0.85, screen.availHeight * 0.85);</pre>
<pre>//-------Rename left menu link / Left Navigation. Example: Contacts
var navItem = document.getElementById(’navContacts’);
navItem.innerHTML = navItem.innerHTML.replace(’&gt;Contacts’,'&gt;Students’);</pre>
<pre>//------Hide left menu link / Navigation. Example: Workflow
var navLeftItem = document.getElementById(’navAsyncOperations’);
navLeftItem.style.display = ‘none’;</pre>
<pre>//-----Hide Left navigation menu item link of a CRM form based on
// a value in a picklist on the same form.
//Get contacts left navigation menu item element.
var navLeftItem = document.getElementById(’navContacts’);
//if picklist (customer type code) value is equal to 1 (1st item in picklist) then
//hide left menu item (contacts link is used as an example), otherwise, show it.
if(crmForm.all.customertypecode.DataValue == 1)
{
 navLeftItem.style.display = ‘none’;
}
else
{
 navLeftItem.style.display = ‘inline’;
}</pre>
<pre> //-----Hide a CRM field on a form. example: the "name" field.
crmForm.all.name_c.style.display = 'inline';
crmForm.all.name_d.style.display = 'inline';</pre>
<pre>//-----Hide a CRM field on a form (example: the "name" field)
//based on the selected value in a picklist
if(crmForm.all.customertypecode.DataValue == 1)
{
         crmForm.all.name_c.style.display = 'inline';
         crmForm.all.name_d.style.display = 'inline';
}
else
{
         crmForm.all.name_c.style.display = 'none';
         crmForm.all.name_d.style.display = 'none';
}  ////Add this code to the OnLoad event of the form and
////to the on change event of the picklist attribute (field) as well</pre>
<pre>//---------Function to hide CRM field in a form.
//Function accept fieldname as a parameter and
//boolean parameter to remove (hide) entire row on form
HideField('name'); //replace "name" with your field/attribute name
 
function HideField( fieldName, removeEntireRow )
{
 // Always hide the elements, even if we will be hiding the whole row.
 // This allows us to show another field in this row later without this
 // one showing up.
 var elem = crmForm.all[fieldName + "_c"];
 if( elem != null ) elem.style.display = "none";
 elem = crmForm.all[fieldName + "_d"];
 if( elem != null ) elem.style.display = "none";    
 
 if (removeEntireRow)
 {
  var elem = crmForm.all[fieldName + "_d"];
  if( elem != null ) elem.parentElement.style.display = "none";
 }
}</pre>
<p> This post was written quickly from memory and some code blocks here and there, so you might find some minor spelling mistakes. Please comment below if you find any issues with the script blocks or if you want me to extend this post to include additional script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/02/17/hide-display-resize-and-rename-left-navigation-links-crm-fields-and-attributes-using-javascript-for-microsoft-dyanmics-crm-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
