简体   繁体   English

如何将 CRM Dynamics 2015 表单数据(归档值)传递到具有 JavaScript 功能的 HTML 页面

[英]How to pass CRM Dynamics 2015 Form data(filed values) to an HTML page which has JavaScript functions

I recently acquired a JavaScript API for a web-phone web client.我最近获得了一个用于网络电话网络客户端的 JavaScript API。 From CRM I want to launch this client and pass my CRM Form data to it, I have created a custom ribbon button that has to call that HTML Page and pass relevant data to it.我想从 CRM 启动这个客户端并将我的 CRM 表单数据传递给它,我创建了一个自定义功能区按钮,该按钮必须调用该 HTML 页面并将相关数据传递给它。

The ribbon button should launch the URL to the web-phone, but at the same time pass parameters to the JavaScript functions in the HTML page, do I use JavaScript action on ribbon or do I use URL action , if I use URL how do I pass data to the JScript function?功能区按钮应该启动网络电话的 URL,但同时将参数传递给 HTML 页面中的 JavaScript 函数,我是在功能区上使用 JavaScript 操作还是使用 URL 操作,如果我使用 URL 我该怎么做将数据传递给 JScript 函数?

To make this clearer I have a Contact entity in CRM which has a mobile number that I want to pass as a parameter to the HTML page that has the JavaScript functions I want to utilize for the web-phone client为了更清楚地说明这一点,我在 CRM 中有一个 Contact 实体,它有一个手机号码,我想将它作为参数传递给 HTML 页面,该页面具有我想用于网络电话客户端的 JavaScript 函数

If you are using an url to call the external page you can append the parameters as a "GET" so after calling the page:如果您使用 url 调用外部页面,则可以在调用页面后将参数附加为“GET”:

page.html?phone=123123 page.html?phone=123123

then you will be able to access that from your html page as this other post states Get url parameter jquery Or How to Get Query String Values In js and you should be fine.那么您将能够从您的 html 页面访问它,因为其他帖子指出获取 url 参数 jquery 或如何在 js 中获取查询字符串值,您应该没问题。 Also if you use it as an embedded web resource in the page you will be able to access the form properties via windows.parent.Xrm此外,如果您将其用作页面中的嵌入式 Web 资源,您将能够通过 windows.parent.Xrm 访问表单属性

Add line below to head tag of html:将下面的行添加到 html 的 head 标签:

    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>

Also add this code for running in case of loading of html:还要添加此代码以在加载 html 时运行:

 <script src="OnLoadHtml.js" type="text/javascript"></script>

in javascript OnLoadHtml.js add these codes below:在 javascript OnLoadHtml.js 中添加以下代码:

document.onreadystatechange = function () {
    //When document is ready
    if (document.readyState == "complete") {
        //Get sent arguments in url
        var arguments = GetQueryArgument();
        //Decode encoded arguments
        var decodedArguments = decodeURIComponent(arguments)
    }
}

//Gets query passed argument
function GetQueryArgument()
{
    /*Get the any query string parameters and load them
    into the vals array*/
    var result = "";
    var vals = new Array();
    if (location.search != "") {
        vals = location.search.substr(1).split("&");
        for (var i in vals) {
            vals[i] = vals[i].replace(/\+/g, " ").split("=");
        }
        //look for the parameter named 'data'
        var found = false;
        for (var i in vals) {
            if (vals[i][0].toLowerCase() == "data") {
                result = vals[i][1];
                found = true;
                break;
            }
        }
        if (!found)
        {
            result = "";
        }
    }
    else
    {
        result = "";
    }
    return result;
}

To return result from html to javascript back:要将结果从 html 返回到 javascript:

Add line below to body tag of html:将下面的行添加到 html 的 body 标签中:

    <input id="btnOk" type="button" class="NormalButton" value="OK" onclick="BtnOK_OnClick();">

And add this code below for javascript part:并在下面为 javascript 部分添加此代码:

//On ok button pressed
function BtnOK_OnClick() {
    debugger;
    console.log("Ok is clicked");
    var result = GetResult();
    //Control value is not empty
    if (result === "")
    {
        retrun;
    }
    Mscrm.Utilities.setReturnValue(result);
    try
    {
        closeWindow(true); // Close the dialog box
    }
    catch (e)
    {
        console.log("Error happened at closing.");
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Dynamics CRM 2015中向表单添加按钮 - How to add a button to a form in Dynamics CRM 2015 从弹出式CRM Dynamics 2015中的父表单获取数据 - Get data from parent form in a popup CRM Dynamics 2015 Dynamics CRM 2015:如何获得创建的Web资源按钮以引用添加到表单的Javascript库中的函数? - Dynamics CRM 2015: How do I get a Web Resource button I created to reference a function in a Javascript Library I added to the form? 从 MS Dynamics CRM 中的 html webresource 窗口传递数据 - Pass data from html webresource window in MS Dynamics CRM CRM Dynamics,如何使用一种形式传递值,并使用Xrm.Utility.openEntityForm()在新的Entity(form)中设置值; - CRM Dynamics , How to pass values from one form and set the values in a new Entity(form) using Xrm.Utility.openEntityForm(); 如何在 Dynamics CRM 4.0 中传递 Javascript 中的 Null 值? - How to pass the Null Value in Javascript in Dynamics CRM 4.0? 我想使用纯Javascript从MS Dynamics CRM Online 2015添加/检索数据 - I want to add/retrieve data from MS Dynamics CRM Online 2015 using pure Javascript 如何将值从一个html页面传递到另一个html页面javascript? - How to Pass values form One html Page to Another html Page javascript? CRM Dynamics:将arraybuffer传递给html Web资源 - CRM Dynamics:To pass arraybuffer to html web ressource 如何从插件中调用javascript或刷新microsoft dynamics 2015中的页面 - How to call a javascript from plugin or refresh the page in microsoft dynamics 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM