Skip to main content


Showing posts from 2012

Is Something Missing in Your Organization Service? Check the Cache!

The Developer Extensions for Microsoft Dynamics CRM are extremely helpful tools for developing custom code for CRM.  They provide a simplified way to connect to the CRM Services with the ability to be configured and extended.

One ‘gotcha’ when using the CrmConfigurationManager class to connect to CRM is that the default configuration includes caching of the organization service.  A colleague of mine was running into an issue where the organization service wasn’t recognizing his newly created relationship when developing a query, so he had the need to disable caching.   

To do this, the App.config can be updated with the following XML:

Note that this requires the microsoft.xrm.client section to be declared in the App.config as well.  The full App.config should look something like this:
The examples above are covered in the following MSDN article

IE Developer Tools

I use the IE Developer Tools (or IE Dev Toolbar) almost every day.  I was going to write a post about how to use it but I just discovered today that MSDN already has some great documentation around it.

Here's a good starting point with "Discovering Internet Explorer Developer Tools" -

I would also dive into this article "Debugging Script with the Developer Tools" -  One of the most common issues asked on the CRM forums are javascript errors.  Debugging with the dev toolbar can help solve a lot of those issues.

Another great feature of the dev toolbar is Profiling javascript which this article talks about in depth -  This helps analyze the performance of your javascript and since we write a lot of javascript for CRM it can help optimize your form loading experience.

Upgrading CRM

Here's some great resources on upgrading CRM from previous versions:

Upgrade Microsoft Dynamics CRM -

Microsoft Dynamics CRM Upgrade Tips and Considerations -

Pre-Delete Plugin 'Gotcha'

If you are running a plugin on the pre-operation event of the Delete message, one thing to note is that by that time CRM has already disassociated the record in context with any child records.  Therefore if you need to query for any child records relating to that record, nothing will return from your query.

A way around this would be to register your plugin in the pre-validation event.

Example query that won't return any results in pre-operation Delete of 'recurringappointmentmaster':

CRM 2011 JavaScript Model Generator

I am happy to announce the CRM 2011 JavaScript Model Generator!  This tool will increase developer productivity as well as performance in regards to client-side scripting on CRM 2011 entity forms.
The JS Model Generator will go and grab the Form XML for specified entities and create objects for each attribute, tab, section, and left navigation item that currently exists on the published Main form.  This allows you to use intellisense to see which attributes, tabs, sections, left navigation items exist on the form and also provides easier syntax than using Xrm.Page.  It will generate all this javascript inside an existing javascript file (on the developer's machine, not a CRM web resource).
Form is the base object for referencing the tabs, attributes, sections, and left nav items.  Use Form.Attributes for Attributes, Form.Tabs for Tabs, Form.Sections for Sections and Form.Navigation for Left Nav Items.
The syntax below is the same for each type but one difference is that Form…

Tab Performance - CRM 4.0 vs CRM 2011

Tabs in CRM 4.0 are more like your traditional tabs you see on most web sites.

The nice thing about these style of tabs in CRM 4.0 are that only the content in the selected tab loads when the form loads.  This saves time on the initial hit and it won't load custom pages on other tabs until those tabs are selected.

On the other hand in CRM 2011 the tabs are vertical instead of horizontal.

The issue with vertical tabs is that by default everything loads initially when the form loads.  This includes all Silverlight resources that are on the form.  Also if you have Javascript that hides and shows fields on the form then potentially you could see the form jump around onload.  
In CRM 2011 we can easily get the same performance advantages of CRM 4.0 tabs.  To do this just simply uncheck the tab setting "Expand this tab by default".

By not expanding the tab by default, Silverlight won't load until the tab is clicked so we can get the "on demand" loading like CRM …

Fiddling with CRM

Today I am reposting my guest blog appearance yesterday on the Sonoma Partners Blog.  Enjoy!

Fiddler can be extremely helpful in troubleshooting CRM issues and also great for testing web requests before deploying.  In this post I will go over some of the helpful and maybe not-so-obvious features of Fiddler.

First things first, you can find Fiddler here -  Also to get started we first need to turn on a few settings.

If you are using HTTPS then go into Tools – Fiddler Options -> HTTPS Tab and check the following options:
•Decrypt HTTPS traffic
•Ignore server certificate errors

Next, click on the Composer tab on the right side panel of Fiddler.  Then click on the Options sub-tab and select Automatically Authenticate

With these settings turned on, we can now perform the following techniques.

Request Logging

The main feature of Fiddler is being able to log and inspect web requests being made from the client machine.  In …

Advanced Configuration Settings

I discovered some Advanced Configuration Settings that most people probably don't know about.  You can find them here on this MSDN article:

Note - In the above article, Microsoft suggests that these settings should only be updated when a Microsoft Dynamics CRM Support Rep suggests it.

There are five different types of Advanced Configuration Settings.  They include:

CmdKeySetting - - - - -
These configuration settings can only be updated through the CRM API.  Here's some sample code from the above article on updating these settings:

RetrieveAdvancedSettingsRequest request = new RetrieveAdvancedSetti…

CRM 2011 LINQ - All Columns vs. Selected Columns

When creating LINQ queries in CRM 2011, it is easy enough to return the whole column set of the entity record without even thinking about the impact.  
Below is an example of querying all contacts from Chicago and returning all columns for each contact record.

This can be a big performance impact depending on the amount of columns that exist on the Contact entity and how many contact records exist in the system.  Another issue is that it could cause errors down the line if some of the attribute types are changed in the CRM system since the data is being bound to a model class that could be out-of-sync.
From the MSDN article on constructing LINQ queries (, we can see that the select clause creates a column set:
The select clause defines the form of the data returned. The clause creates a column set based on the query expression results. You can also define an instance of a new object to work with. The newly created object using the…

CRM 2011 Form XML

Retrieving and parsing the Form XML in CRM 2011 is pretty easy.  If you ever had to do this in CRM 4.0 you would know that the Form XML was stored in the OrganizationUI table.  In CRM 2011 it is now stored in the SystemForm table.  
So first things first, we need to build a query to retrieve the Form XML for an entity from the SystemForm table.

In my case, I just have the entity's name so I need to retrieve the entity metadata and find it's type code to use to filter the query.  I also filter the SystemForm Type by 2 which means it is the Main form (
Now that we have my entity's Form XML.  We can build a method to find all the attributes' schema names that exist on the form.  This method just parses the XML string into an XElement and then selects all the id's of the "control" nodes that exist in the Form XML.  This array of id's will be all the schema names of the attributes that exist on the for…

Workflow Debugging - CRM 4.0 vs CRM 2011

In CRM 4.0 debugging workflow errors can be a pain.  If you browse to the system job record, it is in either "Waiting" or "Failed" status.  Opening the record in hopes to find more details just provides you with the infamous generic error "An error has occurred.".  A pro tip if you are in this situation is to run this SQL query against the organization database:

select Message from AsyncOperationBase
order by CreatedOn desc

This will display all the system job records in order of most recent.  The Message column will contain a more detailed error which is very helpful in troubleshooting the workflow instead of the generic error you see in the UI.

For example I have a workflow that executes on status change of a Task and the workflow will try to update that Task record.  When I close a task this workflow will execute and fail.  I can dig into the database by running the SQL query from above to find this very helpful message:

This tells me exactly what the …