I have a problem with a simple javascript in CRM 2011:). I have create a custom entity and a button on the form ribbon. When the button is pressed the following code is executed:
function Process(){
Xrm.Page.getAttribute("statuscode").setValue(229660003);
Xrm.Page.data.entity.save();
}
Now, also if the status reason is updated in the form, the record isn't saved..why? If I change the statuscode with a custom field all work right but why with status reason so not work? With plugin code it aldo works.
Thanks a lot
I have a problem with a simple javascript in CRM 2011:). I have create a custom entity and a button on the form ribbon. When the button is pressed the following code is executed:
function Process(){
Xrm.Page.getAttribute("statuscode").setValue(229660003);
Xrm.Page.data.entity.save();
}
Now, also if the status reason is updated in the form, the record isn't saved..why? If I change the statuscode with a custom field all work right but why with status reason so not work? With plugin code it aldo works.
Thanks a lot
Share Improve this question asked Nov 18, 2013 at 15:23 ocnerFocnerF 482 silver badges7 bronze badges 2- It's been a while but I think I found different behaviours between create and update with statuscode. It also matters if the particular statuscode value is valid for the current statecode – keerz Commented Nov 18, 2013 at 22:23
- Hi, I solved the problem. The status reason was set as a read only field on the form so forcing the submitmode to always is possibile to change it... – ocnerF Commented Dec 13, 2013 at 16:33
3 Answers
Reset to default 2statecode
and statuscode
fields can't be updated as other fields, by JavaScript or by C# inside custom code or plugins.
It is necessary to execute a SetStateRequest
As Guido Preite mentioned, It is necessary to execute a SetStateRequest
. If you want to use JavaScript, you need to make SOAP call.
Please check the solution here:
Set Status or State of a Record
You can use a simple handler which you can call from javascript using a xmlhttprequest.