
I have a calculation field, I am using business rule to calculate the total onSave. I am using JavaScript onLoad to set the default field values to 1.00. The below code works fine onLoad, however onChange it doesn't set back the value back to 1.00. The only time the value need to be set to 1 is onLoad and if the user delete the value. For instance If a user put 10 for one of the field, onSave the total will be calculated. However if they decided to delete the value of the field I want it to be set to 1.00. The below code set it to null. Thanks!!
function onLoad() {
Test("new_field1");
}
function new_field1OnChange() {
Test("new_field1");
}
function Test(fieldName) {
if (Xrm.Page.getAttribute(fieldName).getValue() == null) {
Xrm.Page.getAttribute("new_field1").setValue("1.00");
}
else {
Xrm.Page.getAttribute("new_field1").setValue("");
}
}
*This post is locked for comments
I have the same question (0)Hi MituCRMing,
The field in case it's a Business Required field?
At some versions of CRM ( 2013+ i think) for the required fields, the onChange event is not fired when the user empties the field.
If you can, remove the requirement business for this field, and try to set the requirement rule via Javascript.
This case have been already discussed at:
community.dynamics.com/.../113794
Best Regards,
Felippe Mendonça dos Santos
If this help you, please "Like" and "Mark as Answer"