Friday, September 28, 2012

How to Restrict Saving of a Record in CRM 2011

First make sure you have the 'Pass execution context as first parameter' checkbox ticked when attaching the onSave Event Handler



In the ValidateData method make sure you have a parameter defined to receive the Execution Object.

function ValidateData(ExecutionObj){
     //Place all your data validation here
     //In case data is not valid call the below method
     // The getEventArgs() method returns an object with methods to manage the Save event.
     // The preventDefault() method cancels the save operation
     ExecutionObj.getEventArgs().preventDefault();
}

Refer this link for more details ...

1 comment: