admin管理员组文章数量:1431740
I use Mscrm.CrmDialog to show a new dialog with a webresource in MS Dynamics CRM 2013. The advantage of this method is that this dialog works in Firefox, Chrome, etc. too and window.showModalDialog doesn't because it is deprecated.
Anyway I need to pass parameters to the webresource. With window.showModalDialog this was no problem but now when using Mscrm.CrmDialog I couldn't find any way to pass parameters. The constructor has a parameter 'customWindowParameters', but how to access these parameter(s) from the web resource?
I use Mscrm.CrmDialog to show a new dialog with a webresource in MS Dynamics CRM 2013. The advantage of this method is that this dialog works in Firefox, Chrome, etc. too and window.showModalDialog doesn't because it is deprecated.
Anyway I need to pass parameters to the webresource. With window.showModalDialog this was no problem but now when using Mscrm.CrmDialog I couldn't find any way to pass parameters. The constructor has a parameter 'customWindowParameters', but how to access these parameter(s) from the web resource?
Share Improve this question asked Jun 23, 2015 at 12:16 PeterPeter 3912 gold badges5 silver badges18 bronze badges 2- the use of Mscrm.CrmDialog is unsupported – Guido Preite Commented Jun 23, 2015 at 14:25
- I know that it is unsupported. But what is a better solution to show a dialog? The deprecated ModalDialog is unsupported by most browsers too. – Peter Commented Jun 24, 2015 at 7:14
1 Answer
Reset to default 5Declare global variable in the script from where you calling the dialog (Mscrm.CrmDialog) like:
var variable1 = 5;
var object1 = { Id: 1, name: "SWA" };
function ribbon_OpenDialog() {
var clientUrl = Xrm.Page.context.getClientUrl();
var url = clientUrl + "/WebResources/new_myWebResource.html";
//CRM 2015 SP 1
var dialogwindow = new parent.Mscrm.CrmDialog(parent.Mscrm.CrmUri.create(url), this, 450, 175);
//For CRM less than CRM 2015 SP 1
//var dialogwindow = new Mscrm.CrmDialog(Mscrm.CrmUri.create(url), this, 450, 175);
dialogwindow.show();
}
The above globally declared variables can be accessed in the webresource through window.getDialogArguments()
as in the following sample html webresource
<html>
<head>
<title></title>
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script type="text/javascript">
var dialog;
if (window.getDialogArguments() != null) {
dialog = window.getDialogArguments();
}
var v1 = dialog.variable1;
var o1 = dialog.object1;
function doSomthing() {
alert("variable1= " + v1 + "\n object1.Id=" + o1.Id + "\n object1.name=" + o1.name);
}
</script>
<style type="text/css">
.dvrow {
clear: both;
margin: 2px auto 0 auto;
padding: 10px 0 10px 0;
width: 96%;
}
.headerTitle {
font-family: Segoe UI Light, Segoe UI, Tahoma, Arial;
font-size: 27px;
font-weight: lighter;
}
</style>
</head>
<body>
<form id="formPopup">
<div id="spinner">
</div>
<div class="dvrow">
<div class="headerTitle">
Test dialog Popup
</div>
<div class="row">
<button title="Run" id="btnRun" onclick="doSomthing();" type="button">Run</button>
</div>
</div>
</form>
</body>
</html>
Click Run button results:
本文标签: javascriptPass parameters to MscrmCrmDialogStack Overflow
版权声明:本文标题:javascript - Pass parameters to Mscrm.CrmDialog - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745508777a2661372.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论