Category Archives: Customization

Tips and Tricks for customizing Microsoft CRM 3.0

CRM JavaScript Conversion Strategies Summary

Over on my main company site, CRM Accelerators, I have concluded a series on strategies related to converting your JavaScript from Dynamics CRM 4.0 to 2011+.


Here is the summary:

Webinar Recording

I also conducted a free webinar for MSDynamicsWorld recently and you may view that recording here:

Other Resources

Finally, I have a page dedicated to the topic of upgrading from Dynamics CRM 4.0 to 2011+:

It contains links to all of my articles and tools, plus links to articles written by others that I thought would be beneficial.

Setting a Section Label based on a Field Value

I was adding some “fancy” to a Contact form today that I thought I would share with you:


The Concept

On the Contact form, I have added the two sets of addresses that are built into Contact and am calling them Primary Address and Secondary Address.  I thought it would enhance the user experience to change the label when a user specifies the actual type of address.

The result is something like this:



The Implementation

Follow these steps to implement this solution:

Step 1

1. Create two sections on the form to hold the fields, one for Address1 fields, the second for Address2 fields. Each should be configured like this:


2. Add the address fields to the form, to their respective sections.


Step 2

Add the JavaScript above to the web resource for Contact.  If you already have an onLoad method, just add those two lines of code to your method.


Step 2:

Add events to each of the Address Type fields:


Notice that the Pass execution context as first parameter is checked. This is vitally important and the process will not work without it..

Save and publish the form.


Step 3:

Testing using the following protocol:

1. Open a new Contact.

2. Change the value of the Primary Address type.

3. You should see the Primary Address section label change.

4. Repeat steps 1-3 for the Secondary address.

5. Save and close the record.

6. Reopen the record.

7. Verify that the section headers change.


Code Review

Let’s take a deeper dive into the code.  I could have hard-coded the section values into our JavaScript but I thought that it would be better to make a fairly generic version of our code.

Take a look at the beginning of function.

function addressType_onChange(executionContextObj) {
    var field = executionContextObj.getEventSource();

This code gets a handle to the attribute which fired the change event.

Since we are working with an OptionSet, we need to get the label for the currently selected value:

var addressType = field.getText();

Next, a check to make sure we actually have a value:

if (addressType != null && addressType != "") {

And finally, the tricky part:

field.controls.get(0).getParent().setLabel(addressType + " Address")


field is a handle to the attribute, but we need to get to the parent Section where the attribute resides. Unfortunately, the getParent() method is only associate with a form control. 

.controls.get ( 0 ).getParent() will get the parent of the first control associated with the attribute, with the parent being the Section itself

Note: This is making an assumption that the field is not on the form more than once.

Finally, setLabel() is actually going to reset the label for the Section using the value from the Address Type OptionSet and the word Address.



You can use the exact same technique with other field types, but you will need to modify the .getText method to .getValue and change the validity check statement to match the data type being retrieved.

Other than that, this is a pretty simple piece of code.

CRM SDK Nugget: Metadata Browser

Way back when, like in version 3.0 and 4.0, Dynamics CRM had a hidden page that would display a list of entities and attributes in a concise list.

That went away in version 2011 but the good folks on the CRM SDK team (Jim specifically), created a managed solution that was included in the SDK.

The main purpose of the tool is to show you information about CRM entities that does not show up on the normal CRM user interface through the dialogs associated with solutions.  This information is available, but only available via programmatic access.

My utility SnapShot! for Dynamics CRM uses exactly the same techniques to produce reports showing information not normally seen through the CRM UI.



After you have downloaded and installed the SDK, you can find the Metadata Browser here:


Install the Metadata Browser as you would any other managed solution. When finished, open the solution and go to the Configuration page, where you can launch the different Metadata Browser components.


Metadata Browser

The first tool is the main Metadata Browser itself, which you activate by clicking the Open Metadata Browser button:


The interface looks like this:


As you click on an entity on the left-hand side, it’s properties will be displayed on the right.

At this point you can either view or edit the entity and its details.


Entity Metadata Browser

The second function will display a dialog that will allow you to edit an entity. This is the same dialog that is shown when you click the Edit Entity button on the Metadata Browser.

Here is what that interface looks like:


As you can see, you can edit or view any of the properties of the entity.


In conclusion, this is a simple yet powerful tool and one that is often overlooked but one which is great to have in your toolbox, should you need it.

Updated: How much space are my Attachments using? (OnPremise)

I was digging through a customer’s CRM database today to determine where all of the space had gone and thought I would share a couple of SQL scripts I created to help.

Note: You’ll need Administrator access to SQL to run these scripts.

This script will give you a summary of all Annotations, broken down by MimeType, which is the format of the file as it was explained to Dynamics CRM when added to the database.


    COUNT(Mimetype) AS Count,
    SUM(CAST(FileSize / (1024)AS DECIMAL(12,2))) AS 'Size (KB)',
    CAST(SUM(CAST(FileSize AS DECIMAL)) / (1024*1024) AS DECIMAL(12,2)) 
         AS 'Size (MB)'
    MimeType IS NOT NULL

Here are the results:


As you can see, most of the attachments are PDF files.

If you would like to see where all of your attachments reside, try this script:

    COUNT(Annotation.objecttypecode) as Count
    join MetadataSchema.Entity on 
        MetadataSchema.Entity.ObjectTypeCode = annotation.ObjectTypeCode 
group by
order by


Here are the results:


As you can see, most of my attachments are associated with Fax activities. This is expected, in this particular case, because most of the customer’s inbound communications is still via fax.

To locate attachments that are e-mail related, use this script:

    COUNT(Mimetype) AS Count,
    SUM(CAST(FileSize / (1024)AS DECIMAL(12,2))) AS 'Size (KB)',
    CAST(SUM(CAST(FileSize AS DECIMAL)) / (1024*1024) AS DECIMAL(12,2)) AS 'Size (MB)'
    MimeType IS NOT NULL

Which produces the following results:


To see where these attachments reside, run this script:

    COUNT(ActivityAttachment.objecttypecode) as Count
    join MetadataSchema.Entity on 
        MetadataSchema.Entity.ObjectTypeCode = ActivityAttachment.ObjectTypeCode 
group by
order by


Which produces these results:


Upcoming Training: JavaScript Development in Dynamics CRM

I am very excited to announce that my workshop on Dynamics CRM JavaScript Development is now ready. The goal of the class is for me to give you a very thorough introduction to using JavaScript within Dynamics CRM.

After a good deal of consideration, I have decided to take the normal two days of instruction and split it into four days of four hours each.  This should allow students time to better absorb the material as well as get their normal work accomplished.

Here are the specifics:

Session 1
: Monday, January 27th through Thursday, January 30th. 7:00am-11:00am each day.

Register for Session 1


Session 2: Monday, January 27th through Thursday, January 30th. 1:00pm-5:00pm each day.

Register for Session 2


Online using GoTo Meeting.

This is a hands-on workshop with each student provided their own virtual development environment for the duration of the class.

$895 per person (multi-student discounts available)


Note: Due to the interactive nature of this workshop, it will be limited to 10 students.

Student Prerequisite Knowledge:

  • Each student must have working knowledge of Dynamics CRM 2011.
  • Knowledge of JavaScript is also required.

Note: For those students that have not worked with JavaScript previously, a short introduction webinar will be conducted on Friday, January 24th. Students attending this webinar will be expected to have completed the accompanying self-study materials before Monday's class begins. Everyone must be ready to run on Monday for the main class.


Each classroom day will be four hours in length, with the virtual environments available for student use all day, until midnight of January 30th.

And thanks to our virtual development environments, the majority of our time will be spent actually developing JavaScript solutions for Dynamics CRM.

Think labs. Lots and lots of labs. And homework. There will be homework.

We'll cover the following topics:

  • Creating a development environment
    • Setup
    • Source control
    • Working in teams
    • Working with Visual Studio
  • Working with Web Resources
  • Working with Solutions
  • Working with Forms
    • JavaScript libraries
    • Form events
    • Form Event Handler Execution Context Reference
  • Working with the Xrm.Page Object Model
    • Working with Collections
    • Data operations
    • Tabs and Sections
    • Working with Controls
    • Working with iFrames
    • Working with Navigation Items
  • Ribbon button and JavaScript connection
  • Opening Dynamics CRM Forms and Web Resources via JavaScript
  • Using the XrmSrcToolkit to CRM-related data operations

We will be using about 75 of the methods found in the Xrm.Page object model so you should leave class with a fairly good understanding of where things are and how to access them.

If we have time, we will also cover some of the freely available JavaScript components that can be used to aid in your development efforts and to increase your user's productivity.

Students will also receive a draft copy of my upcoming book on Dynamics CRM JavaScript development along with sample code and utility web resources that should help you kick start your CRM JavaScript development efforts.


Please email me if you have any questions: mitch at crmaccelerators dot net

ALM for Microsoft Dynamics CRM 2011: CRM Solution Lifecycle Management

As Microsoft Dynamics CRM continues pushing towards the enterprise space, it becomes increasingly important to support the requirements of the enterprise—not only through the product but also in terms of functionality, scale, resilience, and security.

From an implementation perspective, enterprises expect to be able to have structured, repeatable processes that are predictable and well documented to manage their application lifecycle.

To date, a number of approaches have been articulated through various channels and from a variety of sources, but a definitive and full lifecycle approach has not been concisely communicated by Microsoft.

Many customers, partners, and consultants within MCS are reaching out for best practice advice and guidance, and it is Microsoft’s responsibility to deliver on this expectation. This document focuses on providing a coherent end-to-end approach to enterprise development for Dynamics CRM.

Dynamics CRM SDK Version 5.0.15 Released

Microsoft Dynamics CRM SDK Version 5.0.15 is now live on MSDN downloads and in the MSDN library.

New and updated topics

Updated the assemblies for Microsoft Dynamics CRM 2011 Update Rollup 13. These assemblies are also compatible with Microsoft Dynamics CRM Online.
Updated the readme for this version of the SDK package.
Browse the Metadata for Your Organization

Updated the metadata browser so that the HasChanged and RelationshipType properties added in Microsoft Dynamics CRM 2011 Update Rollup 12 and the Microsoft Dynamics CRM December 2012 Service Update can be viewed.
Design Considerations for Different Form Presentations
Added the Auto Save Control for Updated Forms section to provide more details about the auto save control behavior.
Added to the remarks for the Targets property to indicate that the attribute is not supported if the Targets property is null.
<Scrolling> (FormXml)
Updated the topic to provide examples of valid values for this element.
Added the description “For internal use only.” for the phone value added in Microsoft Dynamics CRM 2011 Update Rollup 12 and the Microsoft Dynamics CRM December 2012 Service Update.
Tutorials for Learning About Development for Microsoft Dynamics CRM
Updated the list of walkthroughs. Added links to the sample code and walkthrough categorized views on the Developer Center on MSDN. Added a section for links to other developer resources and social media.
Use Form and Field Events
Added more information to the OnChange Event section about when this event occurs. Attribute Methods
Added a new sample to Controls Collection showing how to use the attribute controls collection to show or hide all the controls for an attribute.

Here's a Shout-Out to the Dynamics CRM SDK Team

I don't think enough Dynamics CRM developers understand the amount of time and effort that the SDK team has put into creating documentation and samples so that we may better understand and use the product.

So, I thought I'd throw out some numbers and compare the CRM 4.0 SDK with the 2011 SDK:


Dynamics CRM 4.0 SDK


The SDK help file is 12MB in size.


Dynamics CRM 2011 SDK


The SDK help file is 20MB in size.


That is a lot of work for such a small team

Thanks guys and gals.

Tomorrow's Webinar: JavaScripting in Dynamics CRM 2011

JavaScript allows an administrator to enhance the functionality of Dynamics CRM 2011 in order to better fit your business processes.

This session delivers an introduction to JavaScript development and will cover the following topics:

  • Setting up your development environment
  • Introduction to the form editor
  • Using web resources
  • CRM form events
  • JavaScript basics
  • CRM 2011 JavaScript object model
  • Common CRM JavaScript methods

Class Duration:

1 hour, 30 minutes


Cost Per Attendee:


Eventbrite - JavaScripting in Dynamics CRM 2011 JavaScripting in Dynamics CRM 2011


What to Expect:

At the end of this session, you should at least understand basics of how to write JavaScript and how to utilize the Dynamics CRM 2011 object model to perform the most operations commonly performed by a developer.

Additionally, since this is not a full class, you'll receive homework to be completed on your own, at your own pace.



Friday, March 15th, 1:00pm Central time (U.S.)


About Your Instructor:

Mitch Milam is a seven-time Most Valuable Professional (MVP) for Dynamics CRM, a Microsoft Certified Trainer (MCT), and an independent consultant based in Dallas, Texas.