gpt4 book ai didi

javascript - MS CRM 2013 - 从链接实体中检索属性以创建 html webresource

转载 作者:行者123 更新时间:2023-11-30 19:11:30 25 4
gpt4 key购买 nike

我需要创建一个 HTML 网络资源来更新 CRM 中的数据。

我正在使用 CrmRestKit 来检索数据。

var fetchxml = [
"<fetch top='50'>",
" <entity name='tisa_qualitycontrolassessment'>",
" <attribute name='tisa_weightrating' />",
" <attribute name='tisa_questionscore' />",
" <attribute name='tisa_qualitycontrolassessmentid' />",
" <attribute name='tisa_questionscorename' />",
" <filter type='and'>",
" <condition attribute='tisa_phonecallid' operator='eq' value='", recordid, "'/>",
" </filter>",
" <link-entity name='tisa_questionqualitycontrolunit' from='tisa_questionqualitycontrolunitid' to='tisa_qualitycontrolunitid' link-type='inner'>",
" <attribute name='tisa_qualitycontrolunitidname' />",
" <attribute name='tisa_questionqualitycontrolunitid' />",
" <attribute name='tisa_name' />",
" <attribute name='tisa_recordcalculation' />",
" <link-entity name='tisa_qualitycontrolunit' from='tisa_qualitycontrolunitid' to='tisa_qualitycontrolunitid' link-type='inner'>",
" <attribute name='tisa_qualitycontrolunitid' />",
" <attribute name='tisa_blockweight' />",
" <attribute name='tisa_name' />",
" </link-entity>",
" </link-entity>",
" </entity>",
"</fetch>",
].join("");

CrmFetchKit.Fetch(fetchxml).then(function(entities){
for(var i = 0, max = entities.length; i < max; i++){
$("assessmentbody").html(i);
}
});

对于没有数据(空值)的列,不会检索属性。有一个选项可以通过 fetchXML 获取所有属性吗?你能告诉我如何获取数据(可能使用 odata 查询)吗?

创建带有更新表单值选项的 HTML 网络资源的最佳实践是什么?

最佳答案

For columns where there is no data(null values) the attribute is not retrieved.

是的,这是 FetchXML 预期的行为。这是无法更改的。如果您的数据集中缺少该列,您可以将其假定为 NULL。

how to get the data (maybe with odata query)?

当然,您可以使用 FetchXML Builder in XrmToolBox 。粘贴上面的查询并在那里获得等效项。

enter image description here

the best practice to create HTML webresource with option of updating values in a form

我会使用服务请求从 HTML 网络资源字段值直接在 CRM 中进行更新。您可以在您的案例中使用 CRM REST Builder - 2011 端点编写此类查询。

var entity = {};
entity.Name = "Name_updated";
entity.AccountNumber = "123456";

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'00000000-0000-0000-0000-000000000000')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function() {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 204 || this.status === 1223) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));

enter image description here

关于javascript - MS CRM 2013 - 从链接实体中检索属性以创建 html webresource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58417710/

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