gpt4 book ai didi

javascript - Dynamics CRM 365 - 无法访问 HTML 网络资源中的 Xrm.Page.entity

转载 作者:可可西里 更新时间:2023-11-01 13:47:01 26 4
gpt4 key购买 nike

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

<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>

我也尝试过如下获取数据:

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

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

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

最佳答案

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.


更多建议:

Webpage (HTML) web resources

尝试从 window.parent.Xrm.Page 中删除 window

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

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

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

关于javascript - Dynamics CRM 365 - 无法访问 HTML 网络资源中的 Xrm.Page.entity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40927602/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com