Dynamics CRM: Remove Number Formats in Text Boxes
Posted Monday, March 15th, 2010
MSCRM formats all integers according to the Number Format shown in the Format Tab of the System Settings screen. Sometimes you do not want an integer formatted that way, example of this would be a field that captures a year such as 2010 or an ID from a legacy system or ERP system involved in an integration.
To solve this issue, put the following JavaScript on the onLoad event of the Form. This example uses the field called new_legacyid. Just replace new_legacyid with whatever your field name is.
if(crmForm.all.new_legacyid.DataValue != null)
{
crmForm.all.new_legacyid.value = crmForm.all.new_legacyid.DataValue;
}
It is the value attribute, not the DataValue attribute, that is displayed in the browser. The value attribute is what is formatted – it is formatted before the onLoad event fires. Since the DataValue attribute has the raw integer value, you can now set the value to the DataValue, thus bypassing the formatting.
