【问题标题】:MS CRM 2013 - Retrieve attributes from link-entities to create html webresourceMS CRM 2013 - 从链接实体中检索属性以创建 html webresource
【发布时间】:2019-10-16 16:17:52
【问题描述】:

我需要创建一个 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 网络资源的最佳实践?

【问题讨论】:

    标签: javascript html dynamics-crm dynamics-crm-2013


    【解决方案1】:

    对于没有数据(空值)的列,不会检索该属性。

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

    如何获取数据(可能通过 odata 查询)?

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

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

    我会使用服务请求从 HTML webresource 字段值直接在 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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      • 2019-08-27
      相关资源
      最近更新 更多