在前端JS中 call web api

2021-01-12 13:32

阅读:534

标签:hang   var   type   lse   build   change   function   ==   cat   

前端写Web API 已经不是什么特别困难的问题,  我们可以使用 CRM REST Builder(https://github.com/jlattimer/CRMRESTBuilder)来生成想使用的 CRM REST Builder

 

var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + parent.Xrm.Page.data.entity.getId().replace(‘{‘, ‘‘).replace(‘}‘, ‘‘) + ")?$select=accountid,address1_addressid", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 200) {
            var result = JSON.parse(this.response);
            var accountid = result["accountid"];
            var address1_addressid = result["address1_addressid"];
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send();

 

在前端JS中 call web api

标签:hang   var   type   lse   build   change   function   ==   cat   

原文地址:https://www.cnblogs.com/TheMiao/p/12289210.html


评论


亲,登录后才可以留言!