0

我正在尝试从 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>

无论如何,网络编程是我最强的天赋,所以任何人都可以就我如何解决这个问题提供任何建议吗?

4

1 回答 1

1

正如 Guido 所说,我相信您需要参考 ClientGlobalContext.js.aspx。这是描述 GetGlobalContext()的MSDN 文章。这是它提到包含对它的引用的地方。

当您需要表单外的上下文信息时,请在 HTML Web 资源中包含对 ClientGlobalContext.js.aspx 页面的引用。

于 2013-05-20T20:02:25.637 回答