event.returnValue is not working after UR 12 – Fix
We use event.returnValue=false statement, to stop the event execution. (i.e., I can stop my crm form’s save action, if I write event.returnValue=false statement on my onsave() event).
After I upgraded to UR12, I was getting script error, if I use the event.returnValue statement.
Reason
- Update Rollup 12 and December 2012 Service Update support additional browsers by generating HTML that supports W3C standards.
- This requires removing dependencies on HTML components (HTC) that are specific to Internet Explorer.
- Hence event.returnValue statement has been deprecated
Fix
- Use context.getEventArgs().preventDefault() function to cancel the event execution
How do I use this
- First to get “context”, enable the OnSave event handler to pass the execution context as the first parameter to the OnSave event handler.
- Open customization form -> Form Properties and in “Handler Properties” window, select the “Pass execution ….” checkbox
-
- Next in your Jscript , read the context as first parameter
function onsave(context) {
// Prevent the event execution
context.getEventArgs().preventDefault();
}
Get more details on latest CRM JScript changes from this link
🙂
Categories: CRM 2011, JScript
CRM 2011, event.returnValue, JScript, preventDefault
Reblogged this on ifarhansyed and commented:
For the implementers facing challenges post RU 12 on MSCRM 2011.
courtesy: MVP Rajeev P