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

javascript - Saving field updates that are triggered by an OnSave event - Stack Overflow

programmeradmin3浏览0评论

I'm in the process of customizing our CRM solution, but I've run into a problem today. I have a JavaScript that is triggered by the OnSave event. This JavaScript updates a field in the form, and tries to save again.

When the script executes, I can see the field I'm trying to update change, but when the form reloads, that field still has its old value. I've put a little bit of sudo code below. Has any one else ever had this problem?

OnSave

//Update field 
Xrm.Page.getAttribute("fieldname").setValue(value);  
//Set submit mode to always 
Xrm.Page.getAttribute.setSubmitMode("always");  
//Force save 
Xrm.Page.data.entity.save();  

I'm in the process of customizing our CRM solution, but I've run into a problem today. I have a JavaScript that is triggered by the OnSave event. This JavaScript updates a field in the form, and tries to save again.

When the script executes, I can see the field I'm trying to update change, but when the form reloads, that field still has its old value. I've put a little bit of sudo code below. Has any one else ever had this problem?

OnSave

//Update field 
Xrm.Page.getAttribute("fieldname").setValue(value);  
//Set submit mode to always 
Xrm.Page.getAttribute.setSubmitMode("always");  
//Force save 
Xrm.Page.data.entity.save();  
Share Improve this question edited Dec 23, 2011 at 22:30 ccellar 10.3k2 gold badges40 silver badges56 bronze badges asked Dec 23, 2011 at 19:31 Zach WiseZach Wise 211 gold badge1 silver badge2 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

If your posted code has no copy/paste errors, I think this line causes your problem

Xrm.Page.getAttribute.setSubmitMode("always"); 

This should be

Xrm.Page.getAttribute("fieldname").setSubmitMode("always"); 

My answer was no answer more of a cry for help it self. Sorry.

As I stated in I would check the order of setting de submitmode and changing of the value. As it appears you must set the submitmode first and then assign a value.

Now my changes are saved.

发布评论

评论列表(0)

  1. 暂无评论