我想使用JavaScript將自定義實體添加到Dynamics CRM中的自定義解決方案中。我已經(jīng)進行了一些研究,結果發(fā)現(xiàn)可以使用Actions來完成。 AddSolutionComponent應該可以完成這項工作,但由于出錯了,我可能出了點問題400 Request message has unresolved parameters。我要傳遞參數(shù)的實體和解決方案都使用javascript創(chuàng)建,并且可以在crm中找到它們。function associateEntityToSolution(entityId, solutionUniqueName, newSolutionId){ var param = { 'ComponentId': entityId , // newly created entity id 'ComponentType':1, // entity type 'SolutionUniqueName':solutionUniqueName, //newly created solution id 'AddRequiredComponents':false, 'IncludedComponentSettingsValues':null }; var req = new XMLHttpRequest(); req.open("POST", window.parent.opener.Xrm.Page.context.getClientUrl() + "/api/data/v8.2/solutions("+newSolutionId+")/Microsoft.Dynamics.CRM.AddSolutionComponent", 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) { var uri = this.getResponseHeader("OData-EntityId"); var regExp = /\(([^)]+)\)/; var matches = regExp.exec(uri); var newEntityId = matches[1]; associateEntityToSolution(newEntityId,entityUniqueName); } else { window.parent.opener.Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(param));}我在代碼中缺少什么嗎?還有其他解決方案可以使用javascript完成工作嗎?
如何使用Web Api操作AddSolutionComponent使用javascript將實體添加
三國紛爭
2021-04-20 17:18:10