1

We have CRM on-premise installed on Local Network. I wanna change state and statusreason of salesorder ( Order entity ). I saw this link.

And I call the function in this way ( change status to Canceled and statusreason to No Money:

var recordGuid = Xrm.Page.data.entity.getId();
setRecordStatus ("salesorder", recordGuid ,"3", "100001");

But it gives me 400 Bad Request Error ! Could any one help me on this?

Alireza
  • 179
  • 1
  • 2
  • 11
  • As a side note: v1.5 of [Jason Lattimer's RESTBuilder](https://github.com/jlattimer/CRMRESTBuilder/releases) supports CRM 2011. It's a very helpful tool for building OData queries. – Aron Jul 16 '18 at 12:23

1 Answers1

0

You have to use CancelSalesOrderRequest message to achieve this. Javascript SOAP request Code sample can be found in SDK.SAMPLES.CancelSalesOrderRequest

statecode 2 : Canceled is having only valid associated statusreason 4 : No Money

Your code shows 3 : Fulfilled & 100001 : Complete combination. Check it.

Update:

The link you are referring works for most of the CRM entities, but it’s meant for straight forward status changes like Active to Inactive. But special entities like salesorder needs special messages as this status changes involves other background platform activities like updating child salesorderdetail entities.

You can refer this thread also.

  • Thanks for your reply. I can change state from active to submitted by this way : [link](http://crm2011and2013solutions.blogspot.com/2015/10/change-status-using-javascript.html) @Arun Vinoth But wanna go from submitted to canceled ( no money ) or go from submitted to fulfilled. The above link does not work for these to purpose. – Alireza Jul 16 '18 at 06:57
  • I saw that and that helped me ! Thanks alot ! Could please take a look at this thread? [this](https://community.dynamics.com/crm/f/117/t/288298) – Alireza Jul 20 '18 at 07:58