I remember this happening to me when attempting to set the Quantity on Form Load. I had several attempts at coding around it, until giving up after debugging the CRM Javascript that generates the error.
My final solution (can't remember for which client I encountered the issue so the following is pseudo-code from memory) was something like:
function DefaultQuantity() {
window.setTimeout(function () {
if (Xrm.Page.data.entity.attributes.get("quantity").getValue() == null) {
Xrm.Page.data.entity.attributes.get("quantity").setValue(parseFloat(1));
}
}, 500);
}
Basically; "something" in the form wasn't ready for me to set the Quantity attribute and either the delay or merely spawning the function gave it the opportunity to correct itself.
--pogo (pat) @ pogo69.wordpress.com