gpt4 book ai didi

javascript - 在加载子网格表单时获取父属性

转载 作者:行者123 更新时间:2023-11-30 16:31:14 26 4
gpt4 key购买 nike

我有一个实体 A 的表单,上面有一个实体 B 的子网格。子网格(实体 B)的表单包含一个选项集,我的要求是根据实体 A 的属性值限制可以在实体 B 表单上选择的值。如何获取实体 A 属性使用 JavaScript 在实体 B 表单上的值?

最佳答案

可以查询OData endpoint .在此示例中,我假设在联系人表单中并检索父帐户的关系类型属性。

var accountId = Xrm.Page.getAttribute('parentaccountid').getValue()[0].id;
var url = Xrm.Page.context.getClientUrl();

// OData url. Note that you have to use Schema Names (it's case-sensitive)
url = url + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'"+accountId+"')?$select=CustomerTypeCode";

var req = new XMLHttpRequest();
req.open('GET', url, false); // synchronous call, to keep code short
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.send(null);
var retrievedData = JSON.parse(req.responseText);

// accountData.CustomerTypeCode.Value now contains the numerical value of the optionset

关于javascript - 在加载子网格表单时获取父属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33296050/

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