{Customization and Scripting Tip} Workaround for showing some number fields without comma in Dynamics CRM

Dynamics CRM provides a wide range of fields, one of them is whole number fields.

Sometimes there is a requirement to show this whole number fields in Dynamics CRM without the “,” in the value.

This can be easily achieved if we want to remove “,” from all whole number fields by

navigating to Personal settings and remove it for all whole number fields.

However, it is not often the case when I would want to remove comma from all my whole number fields.

So, the workaround?

I went through a few options and choice is totally dependent on the business scenario at hand.

I am taking example of a Year field below:

If you have a pre-set field for year you can go for a lookup field or option set if the number of years

in the field is lesser.

In my case I have done a small text field of length 4 and added some scripting to the same

End result is something like this:

If I enter a non-numeric field in the Text year field and hit save:


When numeric value is entered, lets the user save:


Volla, without a comma, which was indeed the base of the problem.

And the script behind (You can definitely add a year range validation also, I skipped it in

This example):

function onsave(context)


 var stringValue = Xrm.Page.getAttribute(“dynamics_year”).getValue();

 var numberValue = parseInt(stringValue);

    if(isNaN(numberValue)) {

    Xrm.Page.ui.setFormNotification(“Year is not entered in correct format.”, “ERROR”,“1”);

    // Do not let user save









One last thing, to note: During registering the script on save event on the form do not forget

the highlighted checkbox (to pass the context to the script as first parameter):


Hope it helps and Happy CRMing!


3 thoughts on “{Customization and Scripting Tip} Workaround for showing some number fields without comma in Dynamics CRM

  1. The only issue with this approach is that it reduces the searchability of the Year field. For e.g. you can’t do an advanced find where Year < 2015. IMHO, having a comma is a small price to pay for searchability.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s