Advertisements
Home > CRM 2011, JScript > event.returnValue is not working after UR 12 – Fix

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
  • 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
  1. July 15, 2013 at 3:13 PM

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

  1. March 6, 2014 at 5:33 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: