Thursday, October 4, 2012

CRM 2011 conformation alert before saving a record(to prevent save)

function ConfirmonSave(ExecutionObj) {
    var mode = ExecutionObj.getEventArgs().getSaveMode();
    if(mode == "58") {
        var ans = confirm("There are Associated Process Schedule Waypoints ! Do you really want close ?");
        if (ans == true) {
            Xrm.Page.getAttribute("jmh_forceclose").setValue(1);

        }
        else {
            ExecutionObj.getEventArgs().preventDefault()
        }
    }
}

Note:
Call the above method in OnSave event of Form and Select the "Pass execution context as first parameter".
 the above example is for mark as complete(mode="58") conformation .


Thanks to
Athul MT

Reference:
http://athulmt.blogspot.in/2012/09/how-to-restrict-saving-of-record-in-crm.html

http://msdn.microsoft.com/en-us/library/gg509060.aspx

1 comment: