<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The CRM Grid - A Microsoft CRM Blog</title>
	<atom:link href="http://thecrmgrid.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecrmgrid.wordpress.com</link>
	<description>Greg Owens' rose-tinted MS-CRM mumblings</description>
	<lastBuildDate>Thu, 19 Jan 2012 15:23:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thecrmgrid.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The CRM Grid - A Microsoft CRM Blog</title>
		<link>http://thecrmgrid.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thecrmgrid.wordpress.com/osd.xml" title="The CRM Grid - A Microsoft CRM Blog" />
	<atom:link rel='hub' href='http://thecrmgrid.wordpress.com/?pushpress=hub'/>
		<item>
		<title>SSRS &#8211; checking an external image exists</title>
		<link>http://thecrmgrid.wordpress.com/2011/07/15/ssrs-checking-an-external-image-exists/</link>
		<comments>http://thecrmgrid.wordpress.com/2011/07/15/ssrs-checking-an-external-image-exists/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 12:12:06 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=62</guid>
		<description><![CDATA[15 July 2011 &#8211; Updated with working code. I&#8217;ve just noticed that this post had some comments that it wasn&#8217;t working. I fear it may never have worked. I&#8217;ve reviewed the installation where I deployed this code originally and the working, valid code is now listed below. Apologies to anyone who lost time trying to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=62&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#ff0000;"><strong>15 July 2011 &#8211; Updated with working code.</strong></span></p>
<p>I&#8217;ve just noticed that this post had some comments that it wasn&#8217;t working. I fear it may never have worked. I&#8217;ve reviewed the installation where I deployed this code originally and the working, valid code is now listed below. Apologies to anyone who lost time trying to use the original.</p>
<p>&#8212;&#8212;-</p>
<p>SSRS supports adding external images to your reports. This is useful if, like my client, you have images stored in a SharePoint Document Library. Using some commonly-found code for structuring their document libraries, most accounts have had an image called &#8220;main.jpg&#8221; uploaded. If &#8220;main.jpg&#8221; does not exist, there are good business reasons for this.</p>
<p>The client required a report which should include &#8220;main.jpg&#8221;, if it exists. Otherwise no image should be present at all. The problem is that SSRS is only aware of the URL to the image as a simple string. I used SQL to construct a URL string for each record, but SSRS can&#8217;t natively detect whether an image exists at this URL or not. There is a way around this, however. SSRS allows you to embed your own custom code in your report properties. The following code checks whether an image exists at a given URL and returns true or false. This code can be called from an image control&#8217;s &#8220;Hidden&#8221; property, or combined with an expression in the image controls &#8220;Value&#8221; property to manipulate the URL:</p>
<p><pre class="brush: vb;">

Function IsValid(ByVal Url As String) As Boolean
Dim sStream As IO.Stream
Dim URLReq As Net.HttpWebRequest
Dim URLRes As Net.HttpWebResponse

Try
URLReq = Net.WebRequest.Create(Url)
URLReq.Credentials = System.Net.CredentialCache.DefaultCredentials
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
Return False
End Try
End Function
</pre></p>
<p>To use it, copy the code above to your report properties (Report &gt; Report Properties&#8230; &gt; Code), then after inserting an image control (with Image Source of &#8220;Web&#8221;), add the following code to the Hidden property (Image &gt; Visibility &gt; Hidden &gt; Expression&#8230;):</p>
<p><pre class="brush: vb;">
=Code.IsValid(Fields!fieldWithUrlToImage.Value)
</pre></p>
<p>Any suggestions, improvements or alternative approaches are welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=62&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2011/07/15/ssrs-checking-an-external-image-exists/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Is my CRM 2011 server licenced or on trial?</title>
		<link>http://thecrmgrid.wordpress.com/2011/07/07/is-my-crm-2011-server-licenced-or-on-trial/</link>
		<comments>http://thecrmgrid.wordpress.com/2011/07/07/is-my-crm-2011-server-licenced-or-on-trial/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 11:59:40 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 2011]]></category>
		<category><![CDATA[dynamics crm]]></category>
		<category><![CDATA[licence key]]></category>
		<category><![CDATA[license key]]></category>
		<category><![CDATA[mscrm]]></category>
		<category><![CDATA[product id]]></category>
		<category><![CDATA[product key]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=231</guid>
		<description><![CDATA[There is no obvious way to determine if you CRM server is using a trial licence key or a full licence key. You can infer if you are on trial or not bu looking in Deployment Manager on the CRM Server. An unregistered CRM 2011 installation will show a Product ID in Deployment Manager with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=231&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is no obvious way to determine if you CRM server is using a trial licence key or a full licence key. You can infer if you are on trial or not bu looking in Deployment Manager on the CRM Server.</p>
<p>An unregistered CRM 2011 installation will show a Product ID in Deployment Manager with the format:<br />
XXXXX-010-XXXXXXX-XXXXX</p>
<p>A registered installation will show Product ID in the format:<br />
XXXXX-<span style="color:#ff0000;"><strong>06</strong></span>X-XXXXXXX-XXXXX</p>
<p>If you want further reassuramce, you can confirm if the key you have installed is a full key by attempting to change it to a trial Licence Key via &#8220;Change Product Key&#8221; in deployment Manager. If a full key has previously been applied, you will recieve an error if you try to change it to a trial key.</p>
<p>Trial keys:</p>
<ul>
<li>Microsoft Dynamics CRM Workgroup Server 2011 (5 CAL limit): H84KC-JH8DF-7PDYK-TXBXR-2RMMT</li>
<li>Microsoft Dynamics CRM Server 2011 (no CAL limit): MQM2H-JYYRB-RRD6J-8WBBC-CVBD3</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=231&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2011/07/07/is-my-crm-2011-server-licenced-or-on-trial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Deleting Users in MS CRM 4.0</title>
		<link>http://thecrmgrid.wordpress.com/2011/04/04/deleting-users-in-ms-crm-4-0/</link>
		<comments>http://thecrmgrid.wordpress.com/2011/04/04/deleting-users-in-ms-crm-4-0/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 11:23:04 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=211</guid>
		<description><![CDATA[I have a SQL script (which was previously published on this page) which will allow you to delete a user fully and completely from Microsoft Dynamics CRM 4.0. It is, of course, utterly wrong and unsupported to do this, but still &#8211; the script exists and seems to work just fine. I originally wrote it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=211&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have a SQL script (which was previously published on this page) which will allow you to delete a user fully and completely from Microsoft Dynamics CRM 4.0. It is, of course, utterly wrong and unsupported to do this, but still &#8211; the script exists and seems to work just fine.</p>
<p>I originally wrote it to carry out some particularly unsupported work with a previous client. Later on, I found use for it on more than one occasion during my own development (specifically when importing clients&#8217; existing databases into my own Virtual Machines).</p>
<p><strong>I&#8217;ve pulled the script from here but will happily provide it to anyone who specifically requests it.</strong> I have removed it since even my own tenuous example of how it might be useful turned out to be overengineered. I had suggested that deleting users might be an easy option when importing databases full of users into a development environment, but where you the developer don&#8217;t want the overhead of creating AD accounts and then mapping those users. Ivan (comments, below) has correctly pointed out behaviour which I was previously aware of but had slipped my memory: mapping users is not mandatory during the &#8220;Import Organisation&#8221; process (well, you need to map at least one user, but otherwise&#8230;). Despite showing an &#8220;Error&#8221; during the mapping process, so long as at least one user has been mapped, one can opt to ignore the issue and proceed with the import. Thank  you Ivan.</p>
<p>This makes the script even less tenable than I had thought, so I decided to take it offline. Still, if you want a copy drop me a line &#8211; just be aware that the reason you can&#8217;t delete a user in CRM is that there are usually different ways to approach the problem.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=211&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2011/04/04/deleting-users-in-ms-crm-4-0/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Disabled fields incorrectly saving to the CRM database</title>
		<link>http://thecrmgrid.wordpress.com/2011/01/26/disabled-fields-incorrectly-saving-to-the-crm-database/</link>
		<comments>http://thecrmgrid.wordpress.com/2011/01/26/disabled-fields-incorrectly-saving-to-the-crm-database/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 16:52:47 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>
		<category><![CDATA[Plug-In]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=186</guid>
		<description><![CDATA[Earlier this week, I encountered what seems to be a bug in MS CRM 4.0 which I had not noticed before. This occurred with Update Rollup 13 and Update Rollup 14 (and possibly others&#8230;?) and has been replicated on at least one other unrelated environment. (Edit: but not replicable on all environments&#8230;) The problem manifests [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=186&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Earlier this week, I encountered what seems to be a bug in MS CRM 4.0 which I had not noticed before. This occurred with Update Rollup 13 and Update Rollup 14 (and possibly others&#8230;?) and has been replicated on at least one other unrelated environment. (Edit: but not replicable on all environments&#8230;)</p>
<p>The problem manifests itself with fields marked on the CRM Form Designer as &#8220;readonly&#8221; being incorrectly saved back to the database, during the <strong>create</strong> stage. Strangely on affected machines I was unable to replicate this problem when updating records (which behaved as expected).</p>
<p>According to the CRM 4.0 SDK, readonly/disabled fields are not submitted to the server during the save process. After all, that&#8217;s what the ForceSubmit method is for (my emphasis):</p>
<blockquote><p>All <em>enabled</em> fields will be submitted after they have been modified either through script or by user input.</p></blockquote>
<p>Contrary to this, on creation of a record, data in read-only fields is currently being submitted and saved to the database. I haven&#8217;t identified why this occurs on some deployments and not on others. Details of the main environment that I have encountered this on are listed at the end of this posting. To test your environment, try following these steps:</p>
<ul>
<li>Create a new entity, &#8220;new_test&#8221;</li>
<li>Create a new string attribute, &#8220;&#8221;new_editablestring&#8221;</li>
<li>Create a new string attribute, &#8220;&#8221;new_readonlystring&#8221;</li>
<li>Place both fields onto the form</li>
<li>Mark &#8220;new_readonlystring&#8221; as Read-Only</li>
<li>Enable the &#8220;onchange&#8221; event for &#8220;new_editablestring&#8221;</li>
<li>Add the following script to the onchange event handler<br />
<pre class="brush: jscript;">crmForm.all.new_readonlystring.DataValue = crmForm.all.new_editablestring.DataValue;</pre></li>
<li>Save &amp; publish the form</li>
<li>Create a new_test record</li>
<li>Enter a value in the Editable String field, e.g. &#8220;Creation String&#8221;</li>
<li>Note that the ReadOnly string value is correctly changed on screen</li>
<li>Hit save &amp; close</li>
<li>Open the record again, note that the &#8220;new_readonlystring&#8221; now contains a value &#8220;Creation String&#8221;</li>
<li>Enter a new value in the Editable String field, e.g. &#8220;Edited String&#8221;</li>
<li>Note that the ReadOnly string value is correctly changed on screen to &#8220;Edited String&#8221;</li>
<li>Hit save &amp; close</li>
<li>Open the record again, note that the &#8220;new_readonlystring&#8221; still contains a value &#8220;Creation String&#8221; as it was correctly NOT updated</li>
</ul>
<p>After some testing, it became clear that no permutation of programatically setting the field to Disabled, disabled, readOnly, ReadOnly or readonly made any difference. The only answer, it seems, is to prevent read-only attributes from hitting the database via a plugin. This is simple enough &#8211; the Create message accepts a Target input parameter which is a DynamicEntity. We can simply remove the unwanted properties from the DynamicEntity before the Target gets commited. This is difficult to manage though &#8211; every time you make a field read only on your form, you would need to recompile your code, or update your plug-in configuration strings (depending on how you chose to handle this). There is however a better solution &#8211; retrieve the form definition from the CRM platform, identify which fields should be read-only and omit them dynamically from the input target. And here is how this is done:</p>
<p><pre class="brush: cpp;">
using System;
using System.Xml;
using Vitalogy.XRM.Common;
using Vitalogy.XRM.Plugins.BaseClass;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

namespace Vitalogy.XRM.Plugins
{
public class AllEntitiesCreate : VitalogyBasePluginClass, IPlugin
{
///
/// Identifies read-only fields from the form and ensures that they
/// are not saved to the database (this shouldn't happen anyway
/// but there appears to be a bug in the CRM platform)
///
/// &lt;param name=&quot;context&quot; /&gt;
public void Execute(IPluginExecutionContext context)
{
if (!PluginShouldRun(context))
{
DebugLog.LogMessage(string.Format(&quot;Plug-In \&quot;{0}\&quot; is not designed to run in this scenario&quot;, GetType().Name));
return;
}

DebugLog.LogStart();
try
{
var entity = (DynamicEntity)context.InputParameters.Properties[ParameterName.Target];

// Filter out read-only attributes from the create message
FilterReadOnlyAttributes(context, entity);

}
catch (System.Web.Services.Protocols.SoapException ex)
{
DebugLog.LogError(string.Format(&quot;A SOAP error occurred in the {0} plug-in.\n\n{1}&quot;, GetType(), ex.Detail), ex);
throw new InvalidPluginExecutionException(
String.Format(&quot;A SOAP error occurred in the {0} plug-in.&quot;, GetType()), ex);
}
catch (Exception ex)
{
DebugLog.LogError(string.Format(&quot;A general exception occurred in the {0} plug-in.&quot;, GetType()), ex);
throw new InvalidPluginExecutionException(
String.Format(&quot;A general exception occurred in the {0} plug-in.&quot;, GetType()), ex);
}
finally
{
DebugLog.LogFinish();
}
}

private static void FilterReadOnlyAttributes(IPluginExecutionContext context, DynamicEntity entity)
{
using (var crmService = context.CreateCrmService(true))
{
DebugLog.LogMessage(&quot;Plug-in to strip out read-only fields during record creation&quot;);
// get formxml
DebugLog.LogMessage(string.Format(&quot;Getting formXml for entity {0}&quot;, entity.Name));
// RetrieveFormXmlRequest is unsupported since it is for &quot;internal use
// only&quot; but the alternative involves getting the entity type code
// from metadataservice then issuing a request for OrganisationUI
// for the given entity. This too is deprecated due to not being
// supported in CRM 2011 - but what are we to do, eh?
var formXmlRequest = new RetrieveFormXmlRequest {EntityName = entity.Name};
var formXmlResponse = (RetrieveFormXmlResponse) crmService.Execute(formXmlRequest);
var formXml = formXmlResponse.FormXml;
DebugLog.LogMessage(string.Format(&quot;Retrieved formXml: {0}&quot;, formXml));

// xpath to identify read-only fields
var formXmlDocument = new XmlDocument();
formXmlDocument.LoadXml(formXml);
var disabledAttributes = formXmlDocument.SelectNodes(&quot;//control[@disabled='true']/@id&quot;);

// pluck them out of the create message
if (disabledAttributes == null)
{
DebugLog.LogMessage(&quot;No read-only attributes found&quot;);
return;
}

DebugLog.LogMessage(string.Format(&quot;Retrieved {0} read-only attributes&quot;, disabledAttributes.Count));
foreach (XmlNode disabledAttribute in disabledAttributes)
{
DebugLog.LogMessage(string.Format(&quot;{0} is read-only&quot;, disabledAttribute.Value));
if (entity.Properties.Contains(disabledAttribute.Value))
{
DebugLog.LogMessage(&quot;and has been removed from the Target input parameter&quot;);
entity.Properties.Remove(disabledAttribute.Value);
}
}
context.InputParameters[ParameterName.Target] = entity;
}
}

private static bool PluginShouldRun(IPluginExecutionContext context)
{
// only run if in the pre-Create stage
if (context.Stage == MessageProcessingStage.BeforeMainOperationOutsideTransaction)
{
if (context.InputParameters.Properties.Contains(ParameterName.Target) &amp;&amp;
(context.InputParameters.Properties[ParameterName.Target] is DynamicEntity))
{
return context.MessageName == MessageName.Create;
}
return false;
}
return false;
}

}
}
</pre></p>
<p>A few things to note:</p>
<ul>
<li>Vitalogy.XRM.Common and Vitalogy.XRM.Plugins.BaseClass are simply used to implement the <a href="http://logging.apache.org/log4net/">log4net</a> logging framework (and hence define DebugLog).</li>
<li>This implementation is very simplistic so isn&#8217;t exactly efficient &#8211; the next step would be to cache the list of read-only fields so that it is not being read at every Create</li>
<li>This code can only deal with fields defined as &#8220;ReadOnly&#8221; in the form definition. If you have client-side onLoad script which disables fields onLoad this code will not identify those fields (though if you&#8217;ve coded consistently, you might be able to examine your client-side code within the formXml to find these cases&#8230;).</li>
</ul>
<h3>My environment</h3>
<p>I encountered the aforementioned issue in the following conditions:</p>
<ul>
<li>Combined Application and Database server</li>
<li>Microsoft Dynamics CRM 4.0 &#8211; Update Rollup 14</li>
<li>Microsoft Windows Server 2008 R2 Standard</li>
<li>Microsoft SQL Server 2008 SP1 (64 Bit)</li>
<li>Various clients, including:
<ul>
<li>Internet Explorer 7 (7.0.5730.13) from client</li>
<li>Internet Explorer 8 (8.0.7600.16385) on server</li>
</ul>
</li>
<li>When signed in as a CRM Administrator or non-administrative user</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/186/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=186&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2011/01/26/disabled-fields-incorrectly-saving-to-the-crm-database/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Campaign Response &#8211; required privileges (or &#8220;how to hide&#8221;)</title>
		<link>http://thecrmgrid.wordpress.com/2010/09/29/campaign-response-required-privileges-or-how-to-hide/</link>
		<comments>http://thecrmgrid.wordpress.com/2010/09/29/campaign-response-required-privileges-or-how-to-hide/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 13:16:42 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=176</guid>
		<description><![CDATA[I&#8217;ve only written the title and I&#8217;ve already over-promised&#8230; So you want to suppress the Campaign Response activity but don&#8217;t want to start hacking at the CRM files. What options have you got? Very few, to be honest. Entity visibility is driven via privileges and by turning off access to the right parts of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=176&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve only written the title and I&#8217;ve already over-promised&#8230;</p>
<p>So you want to suppress the Campaign Response activity but don&#8217;t want to start <a href="http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/a840494b-f890-4d4e-9e87-46b47f05976c">hacking at the CRM files</a>. What options have you got? Very few, to be honest.</p>
<p>Entity visibility is driven via privileges and by turning off access to the right parts of the system, most things can be hidden. The problem comes with the side-effects. Since Campaign Response does not have an explicit permission-set in its own right, it is not obvious as to what needs to be changed to hide it from users. Here&#8217;s the solution &#8211; you can choose to remove access to either:</p>
<ul>
<li><strong>Activity </strong>: [<em>Append</em>] AND <strong>Campaign </strong>: [<em>AppendTo</em>]
<li>OR <strong>Activity </strong>: [<em>AppendTo</em>]
</ul>
<p>By removing access to one of these two groups in the appropriate role(s), Campaign Activity will cease to be shown to all users that are subject to that role (assuming that they don;t have additional roles that grant these permissions). It&#8217;s a bit limiting though since without &#8220;Activity : AppendTo&#8221;, you&#8217;re not going to be able to add Notes or attachments to an Activity and without Activity : Append, you won&#8217;t be able to set Regarding&#8230;</p>
<p>I didn&#8217;t say that this would be helpful!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=176&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2010/09/29/campaign-response-required-privileges-or-how-to-hide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Which privilege failed?</title>
		<link>http://thecrmgrid.wordpress.com/2010/09/13/which-privilege-failed/</link>
		<comments>http://thecrmgrid.wordpress.com/2010/09/13/which-privilege-failed/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 15:06:49 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=169</guid>
		<description><![CDATA[A quick tip that might come in handy if you start editing roles and permissions in your CRM deployment. Often when I start to define completely custom roles, especially when using a brand new role with no existing values, I will encounter an error message when testing the role: Error Description: 0&#215;80040220 SecLib::CheckPrivilege failed. Returned [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=169&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A quick tip that might come in handy if you start editing roles and permissions in your CRM deployment. Often when I start to define completely custom roles, especially when using a brand new role with no existing values, I will encounter an error message when testing the role:</p>
<blockquote><p><strong>Error Description:<br />
0&#215;80040220 SecLib::CheckPrivilege failed. Returned hr = -2147220960, User: 00000000-0000-0000-0000-000000000000, PrivilegeId: a3311f47-2134-44ee-a258-6774018d4bc3 Platform </p>
<p>Error Details:<br />
  0&#215;80040220<br />
  SecLib::CheckPrivilege failed. Returned hr = -2147220960, User: 00000000-0000-0000-0000-000000000000, PrivilegeId: a3311f47-2134-44ee-a258-6774018d4bc3<br />
  Platform</strong></p></blockquote>
<p>So what do I need to change to make this work? MSCRM isn&#8217;t being particularly helpful with this error message, so here&#8217;s how to make it make sense. Run the SQL script below against your [Organization]_MSCRM database. Replace the GUID in the query below with the PrivilegeId GUID in the error message:</p>
<p><pre class="brush: sql;">select [Name] from dbo.PrivilegeBase where privilegeid = 'a3311f47-2134-44ee-a258-6774018d4bc3'</pre></p>
<p>You should get a single result back, like &#8216;prvReadEntity&#8217; (Read access required for &#8220;Entity&#8221; which is found on the Roles matrix under the Customization tab, Entity row, Read column) or &#8216;prvCreateUserSettings&#8217; (Business Management tab, User Settings row, Create column). As you can see, the Name of the privilege should give you the pointer needed to set the required permissions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=169&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2010/09/13/which-privilege-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>You are not a Deployment Administrator</title>
		<link>http://thecrmgrid.wordpress.com/2010/06/04/you-are-not-a-deployment-administrator/</link>
		<comments>http://thecrmgrid.wordpress.com/2010/06/04/you-are-not-a-deployment-administrator/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 10:01:16 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=141</guid>
		<description><![CDATA[We&#8217;ve all seen this error at some point when trying to access the Microsoft Dynamics CRM Deployment Manager on the server: Only the Deployment Administrators are able to use Deployment Manager. You are not a Deployment Administrator. Most of the time this is not a problem at all &#8211; perhaps you&#8217;re logged in with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=141&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen this error at some point when trying to access the Microsoft Dynamics CRM Deployment Manager on the server:</p>
<p><em>Only the Deployment Administrators are able to use Deployment Manager. You are not a Deployment Administrator.</em></p>
<p>Most of the time this is not a problem at all &#8211; perhaps you&#8217;re logged in with the wrong account or you simply need to request that another administrator logs in and adds you to this list. Sometimes it can be trickier though &#8211; perhaps the only administrator is on holiday, has left (and had their account deleted rather than just disabled) or any other number of things that might just ruin your day. The only supported method at this point is a reinstall of CRM. Cripes&#8230;!</p>
<p>How about an unsupported method to get you by?</p>
<p>Try this little SQL script which should add you to the list of Deployment Administrators. It is ENTIRELY UNSUPPORTED and probably shouldn&#8217;t be used in a production environment etc etc. But needs must and this might just save your day (but don&#8217;t blame me if I make it worse, right?).</p>
<p><em>IMPORTANT NOTE: This script will get you into the Deployment Administrator, but if you were NOT already a CRM user, it won&#8217;t get you into the CRM front-end. Clearly something missing from my script at present &#8211; be very very careful if you use this in production&#8230;</em></p>
<p><pre class="brush: sql;">
USE MSCRM_CONFIG

DECLARE @username AS VARCHAR(MAX) ,
        @newuserguid AS uniqueidentifier ,
        @userguid AS uniqueidentifier ,
        @adminroleguid AS uniqueidentifier

-- *** TODO:  ADD THE USERNAME YOU WANT TO MAKE A DEPLOYMENT ADMINISTRATOR HERE
SET @username           = '&lt;domain&gt;\&lt;username&gt;' 
SET @newuserguid        = NEWID()

-- Get guid for the Deployment Admin role
SELECT @adminroleguid = id
FROM   dbo.securityrole
WHERE  Name = 'Administrator'

-- Add the user as a systemuser (unless they already exist...)
IF NOT EXISTS
    (SELECT ID
    FROM    SYSTEMUSER
    WHERE   NAME = @username
    )
    BEGIN
            INSERT
            INTO   SYSTEMUSER VALUES
                   (
                          '00000000-0000-0000-0000-000000000000',
                          @newuserguid                            ,
                          @username                               ,
                          0
                   )
    END

-- Get the user's guid
SELECT @userguid = ID
FROM   SYSTEMUSER
WHERE  NAME = @username

-- Add the user's guid and the admin role to the SystemUserRoles table
INSERT
INTO   dbo.SystemUserRoles VALUES
       (
              NEWID()       ,
              @adminroleguid,
              @userguid   ,
              NULL          ,
              0
       )
</pre></p>
<p>We also may need to add the record to the appropriate AD groups and CRM tables. I&#8217;m not going to show you how to add items to Active Directory Groups or which groups to use. Suffice to say, you would need to know the user&#8217;s Active Directory sid (Security ID). Try this command from the server prompt:<br />

dsquery user -name Greg* | dsget user -sid
</p>
<p>This should return a result similar to this:<br />

  sid
  S-1-5-21-0123456789-0123456789-0123456789-1234
dsget succeeded
</p>
<p>You&#8217;re on your own from this point&#8230; <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=141&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2010/06/04/you-are-not-a-deployment-administrator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Dates in FetchXml queries</title>
		<link>http://thecrmgrid.wordpress.com/2010/05/19/dates-in-fetchxml-queries/</link>
		<comments>http://thecrmgrid.wordpress.com/2010/05/19/dates-in-fetchxml-queries/#comments</comments>
		<pubDate>Wed, 19 May 2010 09:08:48 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=136</guid>
		<description><![CDATA[Another quick post. A colleague was trying to execute a FetchXml statement that included a filter on a date field but couldn&#8217;t understand why he was not returning the expected results (indeed, wasn&#8217;t returning any results). At first glance, the query looked fine: The link entity was definitely correct and the date field certainly read [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=136&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Another quick post. A colleague was trying to execute a FetchXml statement that included a filter on a date field but couldn&#8217;t understand why he was not returning the expected results (indeed, wasn&#8217;t returning any results).</p>
<p>At first glance, the query looked fine:</p>
<p><pre class="brush: xml;">
&lt;fetch mapping=&quot;logical&quot;&gt;
	&lt;entity name=&quot;new_entity&quot;&gt;
		&lt;attribute name=&quot;new_entityid&quot;&gt;&lt;/attribute&gt;
		&lt;filter type=&quot;and&quot;&gt;
			&lt;condition attribute=&quot;new_linkentityid&quot; operator=&quot;eq&quot; value=&quot;f25f4cee-e851-df11-bebe-000c29a1faa8&quot;&gt;&lt;/condition&gt;
			&lt;condition attribute=&quot;new_date&quot; operator=&quot;eq&quot; value=&quot;2010-04-30&quot;&gt;&lt;/condition&gt;
		&lt;/filter&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;
</pre></p>
<p>The link entity was definitely correct and the date field certainly read 30th April 2010. The date field was also defined as Date Only in the attribute definition.</p>
<p>It transpired that the problem was (predictably) linked to times. CRM stores all dates in UTC format ()  so even if the attribute is defined as &#8220;Date Only&#8221; in the entity definition, 30th April 2010 will actually be stored as 2010-04-30T00:00:00. For some reason, which I haven&#8217;t yet determined for certain (there are a couple of theories that i don&#8217;t have time to test), the record he was seeking was dated 2010-04-30T<strong>08</strong>:00:00. It may be due to his time zone, since he was working in the US at the time of the problem. It may be that this attribute was previously a Date AND Time attribute and then got changed.  Either way, the simplest solution was to use a different FetchXml operator &#8211; replacing the &#8220;eq&#8221; operator in the &#8220;new_date&#8221; condition with the &#8220;on&#8221; operator thereby ignoring times:</p>
<p><pre class="brush: xml;">
&lt;fetch mapping=&quot;logical&quot;&gt;
	&lt;entity name=&quot;new_entity&quot;&gt;
		&lt;attribute name=&quot;new_entityid&quot;&gt;&lt;/attribute&gt;
		&lt;filter type=&quot;and&quot;&gt;
			&lt;condition attribute=&quot;new_linkentityid&quot; operator=&quot;eq&quot; value=&quot;f25f4cee-e851-df11-bebe-000c29a1faa8&quot;&gt;&lt;/condition&gt;
			&lt;condition attribute=&quot;new_date&quot; operator=&quot;on&quot; value=&quot;2010-04-30&quot;&gt;&lt;/condition&gt;
		&lt;/filter&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;
</pre></p>
<p>A list of FetchXml operators can be found <a href="http://technet.microsoft.com/en-us/library/aa477320.aspx#fetchxmlconditions">on MSDN</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=136&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2010/05/19/dates-in-fetchxml-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Checking the ExecuteFetchRequest message</title>
		<link>http://thecrmgrid.wordpress.com/2010/05/10/checking-the-executefetchrequest-message/</link>
		<comments>http://thecrmgrid.wordpress.com/2010/05/10/checking-the-executefetchrequest-message/#comments</comments>
		<pubDate>Mon, 10 May 2010 10:09:48 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[MSCRM 4.0]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=129</guid>
		<description><![CDATA[Sorry no updates for so long &#8211; NDAs with my main client and 5 hours commuting a day is hammering my blog time! Just a quick note: new version of the CRM SDK is out now &#8211; version 4.0.12. One of the items I noted was a technique to improve the performance of plugins that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=129&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sorry no updates for so long &#8211; NDAs with my main client and 5 hours commuting a day is hammering my blog time!</p>
<p>Just a quick note: new version of the CRM SDK is out now &#8211; <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=82E632A7-FAF9-41E0-8EC1-A2662AAE9DFB&amp;displaylang=en">version 4.0.12</a>.</p>
<p>One of the items I noted was a technique to <a href="http://msdn.microsoft.com/en-us/library/bb955073%28v=MSDN.10%29.aspx">improve the performance of plugins that operate on the Execute message</a>. I have been developing various plugins for my client which change and/or calculate data that gets passed to the UI, by harnessing the Retrieve and RetrieveMultiple messages. When data is being displayed a CRMGrid control however, CRM uses the Execute message instead (specifically the ExecuteFetchRequest message, but this can&#8217;t be checked directly).</p>
<p>Given the pervasive nature of Execute message calls (<a href="http://blogs.msdn.com/crm/archive/2008/05/21/plugins-which-message-and-which-pipeline.aspx">tested thanks to David Jennaway&#8217;s work here</a>), we&#8217;d already determined that checks were necessary to processing the majority of calls to the Execute message. After discovering that the Execute message&#8217;s InputParameters only contain a FetchXml property when a grid is being processed, we can exit the plugin code much quicker thereby improving system performance. It&#8217;s nice to know that this is actually the preferred method too!</p>
<p>Here&#8217;s a little sample:<br />
<pre class="brush: csharp;">
    public class ExecuteHandler : IPlugin
    {
        public void Execute(IPluginExecutionContext context)
        {
            if (context.InputParameters.Contains(&quot;FetchXml&quot;))
            {
                if (context.OutputParameters.Contains(&quot;FetchXmlResult&quot;))
                {
                     // here I intercept and change some values in the FetchXmlResult fragment
                }
            }
        }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=129&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2010/05/10/checking-the-executefetchrequest-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows Update killed my app pool!</title>
		<link>http://thecrmgrid.wordpress.com/2009/12/09/windows-update-killed-my-app-pool/</link>
		<comments>http://thecrmgrid.wordpress.com/2009/12/09/windows-update-killed-my-app-pool/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 12:29:21 +0000</pubDate>
		<dc:creator>Greg Owens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[973917]]></category>
		<category><![CDATA[apppool]]></category>
		<category><![CDATA[application pool]]></category>
		<category><![CDATA[app pool]]></category>
		<category><![CDATA[iis6]]></category>
		<category><![CDATA[windows update]]></category>
		<category><![CDATA[windowsupdate]]></category>
		<category><![CDATA[wss]]></category>
		<category><![CDATA[moss]]></category>

		<guid isPermaLink="false">http://thecrmgrid.wordpress.com/?p=118</guid>
		<description><![CDATA[Tried to access my client&#8217;s development server today to find that CRM 4.0 was down. First thing I did was to check IIS, to find that the CRMAppPool was stopped. I tried to restart it &#8211; it looked like it had worked, but alas a refresh showed that it had failed to start properly. After [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=118&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tried to access my client&#8217;s development server today to find that CRM 4.0 was down. First thing I did was to check IIS, to find that the CRMAppPool was stopped. I tried to restart it &#8211; it looked like it had worked, but alas a refresh showed that it had failed to start properly. </p>
<p>After first blaming the client&#8217;s visiting tech who was also working on the server (sorry &#8216;Cheung!), I checked the Event Viewer and the System Log showed a series of messages from my attempt to restart the Application Pool:</p>
<blockquote><p>A process serving application pool &#8216;CRMAppPool&#8217; terminated unexpectedly. The process id was &#8217;3432&#8242;. The process exit code was &#8217;0xffffffff&#8217;.</p></blockquote>
<p>After a few attempts, W3SVC had given up:</p>
<blockquote><p>Application pool &#8216;CRMAppPool&#8217; is being automatically disabled due to a series of failures in the process(es) serving that application pool.</p></blockquote>
<p>Scrolling down, it became clear that the new prime suspect was Windows Update. A number of updates had been installed early this morning. I checked the KB articles for each one until I came across KB973917 (Extended Protection for Authentication in Internet Information Services). I read the article and although some extra configuration was required, it didn&#8217;t seem to fit my scenario (aka, this is a development server and there was a lot of text in the article and I needed to get back to development, rather than poncing about with security updates). The solution for me was to simply uninstall KB973917 and reboot the server.</p>
<p>Microsoft Dynamics CRM 4.0 is now working just fine, though this probably needs some more investigation. I quick straw poll of some of my CRM buddies did not suggest a widespread issue (yet?) but maybe this was because of the particular setup we are using here? </p>
<p>I&#8217;m not about to fully troubleshoot now, but here is some information about the server that was stricken &#8211; maybe it will help you all to pinpoint any issue with your own servers:</p>
<ul>Microsoft Dynamics CRM 4.0 &#8211; Update Rollup 5</ul>
<ul>Microsoft Windows 2003 SP2</ul>
<ul>Internet Information Services 6.0</ul>
<ul>Microsoft SQL Server 2005 SP3</ul>
<ul>All running on one box</ul>
<ul>Application pools running under default Network Service account</ul>
<p>I believe this will not be limited to just CRM &#8211; <a href="http://groups.google.co.uk/group/microsoft.public.windowsupdate/browse_thread/thread/990d3843d3480aa5/a77a416f66f7a742?hl=en&amp;">at least one other report online</a> of it affecting WSS.</p>
<p><strong>Update 1:</strong><br />
Already a lot of hits today &#8211; if this solution works for you, please post and let everyone know. Also summarise your setup so we can work out when this is happening <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update 2:</strong><br />
Kudos to Richard (who has commented below) for discovering that Microsoft have now rushed out a KB article to explain the problem and propose a longer-term fix: <a href="http://support.microsoft.com/Default.aspx?kbid=2009746">http://support.microsoft.com/Default.aspx?kbid=2009746</a>. In short, reinstall Windows 2003 SP2.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecrmgrid.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecrmgrid.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecrmgrid.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecrmgrid.wordpress.com&amp;blog=1975997&amp;post=118&amp;subd=thecrmgrid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecrmgrid.wordpress.com/2009/12/09/windows-update-killed-my-app-pool/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e52dfb296d5000ad5cbe8f8d1c0ba4d?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Grego</media:title>
		</media:content>
	</item>
	</channel>
</rss>
