最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dynamics crm 2011 - How to set statuscode field by javascript - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

3 Answers 3

Reset to default 2

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

You can use a simple handler which you can call from javascript using a xmlhttprequest.

发布评论

评论列表(0)

  1. 暂无评论