1

我已更改salesorder实体并status reasonSubmitted. 我添加了一个在状态中status reason命名的,带有 value 。我可以通过这个请求从( ) 到( ):PreTransportsubmitted100000004Active statepending status reasonSubmitted stateIn-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-ProgressPreTransport在相同的state。我想是因为permission. 我应该为此新设置权限status reason吗?

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

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

XrmServiceToolkit.Soap.SetState("salesorder", Xrm.Page.data.entity.getId(), 1, 100000004,false);
4

1 回答 1

0

抱歉,我无法访问 2011 版本。但是我在CRM Rest builder中测试了下面的代码片段,它运行良好。

我在. status reason (StatusCode)_ _ 确保您正在通过允许的转换,如在此处回答100000000 : Shipping readystatus (StateCode)1 : Submitted

var entity = {};
entity.StateCode = {
    Value: 1
};
entity.StatusCode = {
    Value: 100000000
};

XrmServiceToolkit.Rest.Update("B4B625A1-3789-E811-A967-000D3A1A9407", entity, "SalesOrderSet", function() {
    //Success - No Return Data - Do Something
}, function(error) {
    Xrm.Utility.alertDialog(error.message);
}, true);

在此处输入图像描述

于 2018-07-20T16:40:21.097 回答