Saturday, March 16, 2013

CRM 2011: Whole Number fields -- dropping the comma

I fielded a request today that involved a CRM field that was configured as a whole number that's intended to store the year component of a date.  In the installation of CRM that I was working in -- numerics are formatted with commas.

The problem that the requestor wanted resolved was that 1995 was appearing in the UI as 1,995 -- they wanted to drop the comma.

I ran across a simple javascript one-liner here that solved the problem.


document.getElementById("fieldname").value = Xrm.Page.data.entity.attributes.get("fieldname").getValue();

The author was quick to point out that the resolution would likely be consider unsupported.  While this is true, I approach these as a measured risk.  It worked for me.


3 comments:

Unknown said...

You can just go to File->Options->Formats and then Set the Number format without the ',' and the Digit Grouping to be grouped together.

Unknown said...

You can just go to File->Options->Formats and then Set the Number format without the ',' delimiter and the Digit Grouping to be grouped together.

jason_koopmans said...

@Srihari: You're right. System-wide changes to the preferences can be made as suggested. In this case, the need to alter the formatting was limited to one field while keeping the remaining preferences what they were.