无法通过JavaScript更改创建的自定义状态原因

时间:2018-07-20 08:11:41

标签: javascript dynamics-crm dynamics-crm-2011 xrmservicetoolkit

我更改了salesorder实体,并在status reason中创建了一个新的Submitted。 我在状态status reason中添加了一个名为PreTransport的{​​{1}},其值为submitted。 我可以通过以下请求从100000004 Activestate)到pending status reason Submittedstate In-Progress):

status reason

但从 var request = "" request += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"; request += " <s:Body>"; request += " <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">"; request += " <request i:type=\"b:SetStateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">"; request += " <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">"; request += " <a:KeyValuePairOfstringanyType>"; request += " <c:key>EntityMoniker</c:key>"; request += " <c:value i:type=\"a:EntityReference\">"; request += " <a:Id>" +recordGuid+ "</a:Id>"; request += " <a:LogicalName>salesorder</a:LogicalName>"; request += " <a:Name i:nil=\"true\" />"; request += " </c:value>"; request += " </a:KeyValuePairOfstringanyType>"; request += " <a:KeyValuePairOfstringanyType>"; request += " <c:key>State</c:key>"; request += " <c:value i:type=\"a:OptionSetValue\">"; request += " <a:Value>"+stateCode+"</a:Value>"; request += " </c:value>"; request += " </a:KeyValuePairOfstringanyType>"; request += " <a:KeyValuePairOfstringanyType>"; request += " <c:key>Status</c:key>"; request += " <c:value i:type=\"a:OptionSetValue\">"; request += " <a:Value>"+statusCode+"</a:Value>"; request += " </c:value>"; request += " </a:KeyValuePairOfstringanyType>"; request += " </a:Parameters>"; request += " <a:RequestId i:nil=\"true\" />"; request += " <a:RequestName>SetState</a:RequestName>"; request += " </request>"; request += " </Execute>"; request += " </s:Body>"; request += "</s:Envelope>"; //send set state request var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web", true) // Responses will return XML. It isn't possible to return JSON. req.setRequestHeader("Accept", "application/xml, text/xml, */*"); req.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute"); var successCallback = null; var errorCallback = null; req.send(request ); In-Progress的{​​{1}}到PreTransport都无效。 我想是因为state。我应该在这个新的permission上设置权限吗?

如果是,我该怎么做? 请注意,我有CRM 2011内部部署。

注意:我也尝试过此代码,但没有成功。

status reason

1 个答案:

答案 0 :(得分:0)

抱歉,我无权访问2011版本。但是我在CRM Rest builder的以下代码段中对此进行了测试,它可以完美运行。

我在status reason (StatusCode)的{​​{1}}下创建了值100000000 : Shipping ready的自定义status (StateCode)。确保您正在经历允许的过渡,例如answered here

1 : Submitted

enter image description here