web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Can not change created custom Status Reason via JavaScript

(0) ShareShare
ReportReport
Posted on by 458

Hi there experts.
I have changed salesorder entity and create a new status reason in Submitted.
I have added a status reason named PreTransport in submitted state, with value 100000004.
I can go from Active state(pending status reason) to Submitted state(In-Progress) via this call web service : 

     var request = ""
               request += "<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\">";
               request += "  <s:Body>";
               request += "    <Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\">";
               request += "      <request i:type=\"b:SetStateRequest\" xmlns:a=\"schemas.microsoft.com/.../Contracts\" xmlns:b=\"schemas.microsoft.com/.../Contracts\">";
               request += "        <a:Parameters xmlns:c=\"schemas.datacontract.org/.../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", "schemas.microsoft.com/.../Execute");
               var successCallback = null;
               var errorCallback = null;
               req.send(request );


But It does not work from In-Progress to PreTransport that are in the same state.
I suppose that it because of permission.
Should I set Permission on this new status reason?
If yes How can I do this? 
Note that I have CRM 2011 on-premise .

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    Like I answered in StackOverflow, its working with Update request. And I don't have access to 2011, also I prefer Update over SetStateRequest.

    [View:https://stackoverflow.com/q/51437987/7920473]

  • Albert_ Profile Picture
    458 on at

    Hi there.

    I have verified that there.

    Thank you .

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans