我正在尝试从 Microsoft Dynamics CRM 2011 中的 HTML 页面启动一个对话框,老实说,我没有得到任何结果。
这是我的 HTML 页面:
<HTML><HEAD>
<META charset=utf-8>
<SCRIPT>
function getServerUrl(){
var context, crmServerUrl;
if (typeof GetGlobalContext != "undefined") {
context = GetGlobalContext();
}
else if (typeof Xrm != "undefined") {
context = Xrm.Page.context;
}
else {
throw new Error("CRM context is not available.");
}
if (context.isOutlookClient() && !context.isOutlookOnline()) {
crmServerUrl = window.location.protocol + "//" + window.location.host;
} else {
crmServerUrl = context.getServerUrl();
crmServerUrl = crmServerUrl.replace(/^(http|https):\/\/([_a-zA-Z0-9\-\.]+)(:([0-9]{1,5}))?/, window.location.protocol + "//" + window.location.host);
crmServerUrl = crmServerUrl.replace(/\/$/, ""); // remove trailing slash if any
}
return crmServerUrl;
}
function LaunchDialog()
{
var string = getServerUrl();
alert(string);
var url="/" + getOrg() + "/cs/dialog/rundialog.aspx?DialogId=%7b7B189BA4-84B4-4E41-AE85-2066A379E502%7d&EntityName=systemuser&ObjectId=" + getUser();
//window.open(url, "", "status=no,scrollbars=no,toolbars=no,menubar=no,location=no");
alert(url);
//window.open(url);
}
function getOrg() {
alert("Called");
///<summary>
/// get organisation
///</summary>
var Org = "";
if (typeof GetGlobalContext == "function") {
var context = GetGlobalContext();
Org = context.getOrgUniqueName();
}
else {
if (typeof Xrm.Page.context == "object") {
Org = Xrm.Page.context.getOrgUniqueName();
}
else
{ throw new Error("Unable to access Organisation name"); }
}
alert("About to return org");
return Org;
}
function getUser() {
alert("Called 1");
///<summary>
/// get logged in user
///</summary>
var User = "";
if (typeof GetGlobalContext == "function") {
var context = GetGlobalContext();
User = context.getUserId();
}
else {
if (typeof Xrm.Page.context == "object") {
User = Xrm.Page.context.getUserId();
}
else
{ throw new Error("Unable to access the UserId"); }
}
alert("End User");
return User;
}
</SCRIPT>
</HEAD>
<BODY contentEditable=true>
<H1>Create Record</H1>
<P><BUTTON onclick=LaunchDialog()>Try it</BUTTON></P></BODY></HTML>
无论如何,网络编程是我最强的天赋,所以任何人都可以就我如何解决这个问题提供任何建议吗?