简体   繁体   中英

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

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

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

您可以使用一个简单的.net处理程序,您可以使用xmlhttprequest从javascript调用它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM