I'm in the process of customizing our CRM solution, but I've run into a problem today. I have a JavaScript that is triggered by the OnSave event. This JavaScript updates a field in the form, and tries to save again.
When the script executes, I can see the field I'm trying to update change, but when the form reloads, that field still has its old value. I've put a little bit of sudo code below. Has any one else ever had this problem?
OnSave
//Update field
Xrm.Page.getAttribute("fieldname").setValue(value);
//Set submit mode to always
Xrm.Page.getAttribute.setSubmitMode("always");
//Force save
Xrm.Page.data.entity.save();
I'm in the process of customizing our CRM solution, but I've run into a problem today. I have a JavaScript that is triggered by the OnSave event. This JavaScript updates a field in the form, and tries to save again.
When the script executes, I can see the field I'm trying to update change, but when the form reloads, that field still has its old value. I've put a little bit of sudo code below. Has any one else ever had this problem?
OnSave
//Update field
Xrm.Page.getAttribute("fieldname").setValue(value);
//Set submit mode to always
Xrm.Page.getAttribute.setSubmitMode("always");
//Force save
Xrm.Page.data.entity.save();
Share
Improve this question
edited Dec 23, 2011 at 22:30
ccellar
10.3k2 gold badges40 silver badges56 bronze badges
asked Dec 23, 2011 at 19:31
Zach WiseZach Wise
211 gold badge1 silver badge2 bronze badges
2 Answers
Reset to default 4If your posted code has no copy/paste errors, I think this line causes your problem
Xrm.Page.getAttribute.setSubmitMode("always");
This should be
Xrm.Page.getAttribute("fieldname").setSubmitMode("always");
My answer was no answer more of a cry for help it self. Sorry.
As I stated in I would check the order of setting de submitmode and changing of the value. As it appears you must set the submitmode first and then assign a value.
Now my changes are saved.