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
var stringValue = Xrm.Page.getAttribute(“dynamics_year”).getValue();
var numberValue = parseInt(stringValue);
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!