简体   繁体   English

如何使用Xrm(Dynamics 365)在主题树中添加新项目

[英]How to add in the subject tree a new item with Xrm (Dynamics 365)

我需要帮助,以使用Xrm和javascript在dynamics 365的主题树中添加新项目。

Subject is like any other entity , you can use web api to create it. 主题就像其他任何实体一样 ,您可以使用网络api来创建它。

function createSubject() {

    var serverURL = Xrm.Page.context.getClientUrl();
    var subject = {};
    subject["title"] = "test subject"; 
    subject["featuremask"] = 1;

    //subject["parentsubject@odata.bind"]="/subjects(<GUID without Quotes>)";  //setting existing lookup

    subject["parentsubject"] = {
        "title": "test parent subject",
        "description": "deep insert to add parent before child",
        "featuremask": 1  
    };

    var req = new XMLHttpRequest();
    req.open("POST", serverURL + "/api/data/v8.2/subjects", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.onreadystatechange = function() {
        if (this.readyState == 4 /* complete */ ) {
            req.onreadystatechange = null;
            if (this.status == 204) {
                var subjectUri = this.getResponseHeader("OData-EntityId");
            } else {
                var error = JSON.parse(this.response).error;
                alert(error.message);
            }
        }
    };
    req.send(JSON.stringify(subject));
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xrm.Page.getControl() 在 Dynamics 365 Sales Hub 中不起作用 - Xrm.Page.getControl() not working in Dynamics 365 Sales Hub MS Dynamics 365-Iframe-Access Xrm-权限被拒绝 - MS Dynamics 365 - Iframe - Access Xrm - permission denied 在Dynamics 365 CRM上使用Xrm Object将表单设置为只读 - Set form read only using Xrm Object on Dynamics 365 CRM 如何将 javascript 添加到 Microsoft Dynamics 365 中的 web 表单 - how to add javascript to a web form in Microsoft Dynamics 365 CRM Dynamics,如何使用一种形式传递值,并使用Xrm.Utility.openEntityForm()在新的Entity(form)中设置值; - CRM Dynamics , How to pass values from one form and set the values in a new Entity(form) using Xrm.Utility.openEntityForm(); 在 Dynamics 365 XRM Web API 中创建记录时无法设置多选选项字段 - Cannot set multi-select option field when creating record in Dynamics 365 XRM Web API Dynamics CRM 365 - 无法访问HTML Web资源中的Xrm.Page.entity - Dynamics CRM 365 - Cannot access Xrm.Page.entity in HTML web ressource 在 JS-Dynamics 365 中使用“Xrm.WebApi.createRecord”创建实体记录 - Create an Entity Record using "Xrm.WebApi.createRecord" in JS- Dynamics 365 如何在主题字段中隐藏主题,就像在 MS Dynamics CRM 2015 中隐藏选项集字段中的项目一样? - How can I hide a subject in subject field, just like hiding an item from optionset field in MS Dynamics CRM 2015? 将工具提示添加到Dynamics 365中子网格中的列名称 - Add tooltip to column name in a subgrid in Dynamics 365
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM