Setting a Dynamics CRM field’s value to Title Case using JavaScript

In a thread on one of the community forms, Debra asked how to properly add some JavaScript she had found on another forum post to make the first letter in each word uppercase (while the remainder is lower-case). This is called title-case, by the way.

Taking the code that Debra mentioned, I modified it a bit, and ended up with this:

function upperCaseField(executionContext) {
    var field = executionContext.getEventSource()


function toTitleCase(str) {
    return str.replace(/\w\S*/g,
                       function(txt) {
                            return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();

It is configured on an individual field like this:


It is most imperative that you check the box for Pass execution context as first parameter.  If you do not, then the function will fail.

If you wish to add this function to multiple fields, you can do so using this technique, as mentioned in that thread by @aileengusni:

function form_OnLoad() {


Dynamics CRM Webinars for May from xRM Coaches


Hi Everyone,

This month I will be holding the following webinars:

Defining and creating your Sales Process within Dynamics CRM

In this webinar we will discuss how you actually define your company's sales process and the steps required to use that process within Dynamics CRM.

Fri, May 13, 2016 10:00 AM – 11:00 AM CDT  Register here.

Introduction to the Dynamics CRM Interactive Service Hub

In this webinar we will discuss the Interactive Service Hub feature of Dynamics CRM 2016 and how it can be used to increase the productivity of your service desk personnel.

Fri, May 20, 2016 10:00 AM – 11:00 AM CDT  Register here.

JavaScript and .NET Code upgrade best practices

In this webinar we will discuss upgrading your JavaScript and .NET code from version the Dynamics CRM 4.0-level APIs to the Dynamics CRM 201x-level APIs.  There is still a lot of code that was never upgrade from 4.0 to 2011 during the initial migration and as companies move toward Dynamics CRM 2016, it is imperative that this code be updated. This is is a follow-up to last Friday's JavaScript upgrade walk-through webinar I did, but It contains a wider range of information.

Fri, May 27, 2016 10:00 AM – 11:00 AM CDT   Register here.

Drop me a line if you have any questions or suggestions.

Thanks, Mitch

Repurposing Dynamics CRM Fields. Just Say No!

I was preforming a pre-upgrade cleanup for a customer when I ran into this:


As you can see, they took a relatively unused field, Address 1: County, and repurposed it and called it Current Software.

This is a very, very, bad thing.

For one, it is totally unnecessary.  Maybe back in the 1980’s when we measured things in kilobytes and megabytes; where gigabytes was just something on a mathmagician’s chart.

But that is not today, when people regularly, and with a straight face, speak of and use petabytes and beyond.

Don’t let me catch you doing this. It is just plain bad design and can lead to fascinatingly odd problems to fix.

Is it time for you to hire a Dynamics CRM Coach?

Hi Everyone,

Have you ever seen a sports team without a coach? Probably not.

Coaches can help guide both the team and the individual players to a higher level of accomplishment and are an integral part of a winning solution.

That is why I created my Dynamics CRM Coaching Program.

The idea is simple: Most of us do not have all of the answers and rather than waste valuable time and energy searching for answers, why not bring in someone with more experience?

Consider these scenarios:

  • Need someone to bounce Dynamics CRM design ideas off of?
  • Need to see if you are on the right track?
  • Have so many “what-if” scenarios lying around you have turned into a mountain of indecision?
  • Not sure of the proper course of action to get your people trained-up enough to support your upcoming rollout?
  • You are trying to bring a product to market but Dynamics CRM is new to you and your team and you are not sure where to start.

If any or all of these sound familiar, then maybe we should talk.

Click here for more information and to find out more about my Dynamics CRM coaching program.

Thanks, Mitch

Update a closed Dynamics CRM Opportunity? Impossible! Yet you can.

Everyone knows that you can’t update a closed record within Dynamics CRM, right?  I mean, everyone knows that.

But what if it was not true?

I ran into a very strange situation last Friday where I was actually able to update a closed Opportunity programmatically – without first reopening it.

This was on a Dynamics CRM 2015 on-premises system and I verified it with Dynamics CRM 2016 Online using an Opportunity that was both closed as Won and Lost.

I am not sure if this is a feature or a bug or if you can do it on any other entities, but at least for Opportunities, that is currently the case.

If anyone else has time to test this process on any other entity, I’d love to know the results.

5 Ways that SnapShot! for Dynamics CRM will save your …

SnapShot! for Dynamics CRM is the ultimate documentation tool for your Microsoft Dynamics CRM organization. It produces reports that can only be created programmatically. Since many of you are not developers, we saved you the time and trouble of writing your own tool, packaged it up into a nice bundle, and did it for you.

Let’s take a quick look at the top 5 ways that SnapShot! can save your [you know what].

1. Security Reports

I discussed this in an earlier article, but have you ever found yourself asking the following questions:

How can I produce a report of all of my security roles and their privileges?

Something strange is happening with this one user and I know it is security-related, but I am not sure why she doesn’t have the permissions that I think she has. How do I figure that out?

SnapShot! has both security role and user privilege reports that can solve both of these problems.

2. Customizations

SnapShot! provides a comprehensive set of metadata and customizations reports for all of the following:

  • Entities
  • Fields
  • Views (with or without detail)
  • Forms
  • OptionSets
  • Relationships
  • Solutions
  • JavaScript library usage
  • Plugins
  • Processes

Or in a nutshell: Everything that I need to see about what has been added to a Dynamics CRM organization. This is the first report I run and review when I start a project at a new customers. It truly gives me a “snapshot” of what has been done and gives me an indication of what may lie ahead.

3. Business Units, Users and Teams

A complete list of all Dynamics CRM Business Units, Users, Teams, and their memberships is provided. This information is exported as an Excel worksheet which can be filtered and sorted. I generally use this combined with the security reports to make sure that people belong to the correct teams or to validate the organizational structure of both business units and teams.

4. Email Configuration

A complete list of email settings from across the system is provided as a single report. This takes into account personal user options, system settings, and mailbox configurations.  I use this all of the time when troubleshooting email delivery or configuration issues.

5. Developer Tools

A wide variety of developer-related functionality is included.  Some may be a bit of an edge-case but they all came out of a specific need that I had while working on various customer projects through the years.

One of the reports consolidates all of the events that need to be tested to validate your JavaScript, plugins, and workflows are working properly. This is typically given to the Quality Assurance department to help them develop a testing plan that will exercise each of the components that have custom code attached, so that it can be properly exercised and verified.


That about wraps it up for today.

Next Steps:

Here is what I would suggest you do next:

1. Download the trial of SnapShot! and run it against your Dynamics CRM organization. It will give you a really great snapshot of your metadata and you can see how it works.

2. Review the sample report.  It was taken from one of my Dynamics CRM Online organizations and will allow you to see what the entire set of reports looks like.

3. Contact me if you have any questions.


Thanks and have a great day.


Sharing information and lessons learned with other developers

Sign up for our new KnowledgeBits service and get news, tips and tricks and more, delivered straight to your inbox.