Search code examples
javascriptdynamics-crm-2011xrm

How to set statuscode field by javascript


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


Solution

  • statecode 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