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
  • Pass execution context
    Pass execution context
  • 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

🙂

Advertisements
Advertisements

2 responses to “event.returnValue is not working after UR 12 – Fix”

  1. ifarhansyed Avatar

    Reblogged this on ifarhansyed and commented:
    For the implementers facing challenges post RU 12 on MSCRM 2011.
    courtesy: MVP Rajeev P

  2. JavaScript Simple Code | hachecrm2011 Avatar

    […] After roll up 12 it doesn’t work without passing the context (from the form properties) to the function and executing only the context.getEventArgs().preventDefault() . More info here. […]

Leave a comment