In CRM 2013 I have some code attached to the "Save" event and it works fine on my opportunity entity. I also need it work when I click on "Save&Close" button, but it just closes the form. I also tried to add some javascript to check
the saveMode and call the appropriate method:
var saveMode = context.getEventArgs().getSaveMode();
if (saveMode == 1) {
Xrm.Page.data.entity.save();
} else if (saveMode == 2) {
Xrm.Page.data.entity.save("saveandclose");
} else if (saveMode == 59) {
Xrm.Page.data.entity.save("saveandnew");
}
but when I use this block I get CRM errors and exception. Has anyone encountered similiar behaviour?