Disclaimer: Feel free to cringe violently when you read this. Try to find another approach if you can. This implementation feels "dirty".
If you open Dynamics CRM 2011/2013/2015/2017/2019 [this article has been future proofed (tm)] in IE11 using a URL pointing directly to an activity instance, for example a phone activity from a call-center application, the window is without an opener or previous state set. This means when you click buttons like MARK COMPLETE that will save and navigate away, you will be presented with the dialog shown in the screenshot above. In normal web development you can get around this IE only feature by navigating nowhere first, see script below:
function closeWindowWithDialog() {
window.close();
};
function closeWindowWithoutDialog() {
window.open('','_self','');
window.close();
};
However, this hack will not work in CRM as Microsoft protected the CRM application from this unsupported usage by suppressing the window.close()
method, and they ask CRM developers to instead use Xrm.Page.ui.close()
. More information here: http://msdn.microsoft.com/en-us/library/gg327828.aspx#BKMK_close
So: To stay supported and get rid of the dialog, open another custom page that redirects the user to CRM using window.open()
. This will set the opener of the window, and the dialog will not appear. I used an MVC controller and a Razor view shown below in an external web application.
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>CRM Redirect</title>
<script type="text/javascript">
window.open("@Html.Raw(ViewBag.CrmUrl)", "_self", "", true);
</script>
</head>
<body>
</body>
</html>
And presto, no dialog is shown! Still, this adds a layer between the user and the application and impacts the performance slightly as there are additional jumps and requests needed from the client's point of view.
*This post is locked for comments