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.