Dynamics CRM 365 - 无法访问HTML Web资源中的Xrm.Page.entity [英] Dynamics CRM 365 - Cannot access Xrm.Page.entity in HTML web ressource

查看:453
本文介绍了Dynamics CRM 365 - 无法访问HTML Web资源中的Xrm.Page.entity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的联系人表单中添加了一个html资源,其中只包含一个小图片,以便将其放在联系人字段旁边。当用户点击它时,它会启动一个javascript函数,我在其中想要获取表单特定字段的值。该字段是联系人实体的属性。
这里是HTML web资源:

 < html> 
< head>
< style type =text / css>
body
{
margin:0;
padding:0;
}
< / style>
< script type =text / javascript>
function call(){
var phoneNumber = window.parent.Xrm.Page.getAttribute(mobilephone)。getValue();
}
< / script>
< meta>
< / head>
< body style =word-wrap:break-word;>
< / body>
< / html>

我也试着得到如下数据:

  window.parent.Xrm.Page.data.entity.attributes.get(telephone1)。getValue()

但它不起作用: 无法读取null实体

问题是getAttribut返回null,尽管我想获取实体的字段。它总是 undefined
有人有想法吗?

解决方案

GetGlobalContext函数和ClientGlobalContext.js.aspx(客户端参考) b
$ b


GetGlobalContext函数使用Web资源
进行编程以访问上下文信息。要在您的HTML Web资源中获取GetGlobalContext
函数,请包含对
ClientGlobalContext.js.aspx的引用。



您可以使用GetGlobalContext函数当您将引用
包含到位于web
资源目录根目录的ClientGlobalContext.js.aspx页面时。







更多建议:

网页(HTML)网页资源 尝试删除窗口 from window.parent.Xrm.Page


添加到表单的HTML web资源不能使用表单中加载的JavaScript库定义
定义的全局对象。 HTML web资源可能
使用parent.Xrm.Page或parent.Xrm.Utility

中的Xrm.Page或Xrm.Utility对象进行交互,但全局由表单脚本定义的对象
不能使用父对象访问。您
应该在
HTML web资源中加载HTML网络资源需要的任何库,以便它们不依赖于加载在
表单中的脚本。


使用IFRAME和web资源控制



尝试从表单脚本传递输入。


对于网页(HTML)网页资源,请使用setSrc方法直接操作
querystring参数。


在HTML页面中,参数可以是通过使用JavaScript中的
window.location.search属性进行访问。


示例:通过数据参数将多个值传递给Web资源


I've added an html resource in my contact form which contains only an small image in order to place it just beside a contact field. When the user clicks on it, it fires up a javascript function in which I want to get the value of a specific field of the form. The field is an attribute of the contact entity. Here is the HTML web ressource:

<html>
<head>
    <style type="text/css">
        body 
        {
         margin: 0;
         padding: 0;
         }
     </style>
    <script type="text/javascript">
        function call() {
            var phoneNumber = window.parent.Xrm.Page.getAttribute("mobilephone").getValue();
        }
    </script>
<meta>
</head>
<body style="word-wrap: break-word;">
    <img onmouseover="this.style.cursor='pointer';" src="/webresources/new_/image/image.png" onclick="call()">
</body>
</html>

I have tried also to get data as follows:

window.parent.Xrm.Page.data.entity.attributes.get("telephone1").getValue()

But it doesn't work either: cannot read entity of null

The problem is that the getAttribut returns null despite the field of the entity that I want to get. It's always undefined Someone has an idea ?

解决方案

GetGlobalContext function and ClientGlobalContext.js.aspx (client-side reference)

Use the GetGlobalContext function when programming with web resources to gain access to context information. To get the GetGlobalContext function in your HTML web resource, include a reference to ClientGlobalContext.js.aspx.

You can use the GetGlobalContext function when you include a reference to the ClientGlobalContext.js.aspx page located at the root of the web resources directory.


Couple more suggestions:

Webpage (HTML) web resources

Try dropping window from window.parent.Xrm.Page.

An HTML web resource added to a form can’t use global objects defined by the JavaScript library loaded in the form. An HTML web resource may interact with the Xrm.Page or Xrm.Utility objects within the form by using parent.Xrm.Page or parent.Xrm.Utility, but global objects defined by form scripts won’t be accessible using the parent. You should load any libraries that an HTML web resource needs within the HTML web resource so they’re not dependent on scripts loaded in the form.

Use IFRAME and web resource controls on a form

Try passing inputs from form script.

For webpage (HTML) web resources, use the setSrc method to manipulate the querystring parameter directly.

In an HTML page, the parameters can be accessed by using the window.location.search property in JavaScript.

Sample: Pass multiple values to a web resource through the data parameter

这篇关于Dynamics CRM 365 - 无法访问HTML Web资源中的Xrm.Page.entity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆