1

本文展示了如何使用 javascript 和 soap 发布网络资源。

http://mileyja.blogspot.com.au/2011/05/how-to-publish-all-customizations-using.html

有没有办法通过 web api 在 javascript 中调用发布请求?

4

1 回答 1

4

是的,完全可以使用PublishAllXmlPublishXml操作。您可以使用CRMRESTBuilder轻松测试这些操作:

PublishAllXml 示例

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/PublishAllXml", 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.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            //Success - No Return Data - Do Something
            alert("it worked!");
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send();

PublishXml 示例(它将仅发布帐户实体):

var parameters = {};
parameters.ParameterXml = "<importexportxml><entities><entity>account</entity></entities></importexportxml>";

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/PublishXml", 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.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            //Success - No Return Data - Do Something
            alert("it worked!");
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send(JSON.stringify(parameters));
于 2017-02-14T14:35:45.863 回答