Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Can not change created custom Status Reason via JavaScript

Posted on by 450

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

  • Albert_ Profile Picture
    Albert_ 450 on at
    RE: Can not change created custom Status Reason via JavaScript

    Hi there.

    I have verified that there.

    Thank you .

  • Verified answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: Can not change created custom Status Reason via JavaScript

    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]

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans