Tuesday, August 12, 2014

detachCloseAlert 2013

Although the detach Close Alert method exist in 2013 code it doesn’t work.
Instead you should use the following peace of code.

//this seems to work only in chrome
Mscrm.RefreshPageHandler.set_forceNavigationAway(true);
//this seems to work both in IE and chrome 
Mscrm.ReadFormUtilities.set_forceNavigationAway(true);

If you need to check the value of the force Navigation flag you can use:

Mscrm.RefreshPageHandler.get_forceNavigationAway(true);

If you what to change the actual text that appear inside the close alert you can change the
Following variable LOCID_FORMS_SAVE_CONFIRM_TITLE. e.g.

LOCID_FORMS_SAVE_CONFIRM_TITLE  = "There are unsaved changes ... "

The downside to this is that you can only assign a static string to LOCID_FORMS_SAVE_CONFIRM_TITLE.
This of course is totally unsupported so use it at your own risk.

Cheers,


1 comment:

  1. Hi,

    this code : Mscrm.ReadFormUtilities.set_forceNavigationAway(true); will remove alert message but your changed data will not save in database because of this line.

    do you have any idea on this ?

    ReplyDelete