Recently had an issue where a series of calculated custom fields were inserted by a VAR, which would calculate the opportunity forecast value and another value for a forecast probability value.
Code was placed on the OnLoad(), to perform this action, but changes to this form would not save. So users could edit further percentages, but reports and views would not reflect the new value.
What I discovered, is that these fields were locked from saving data, as they were marked as read only. This was strange behavior, as new opportunities did not suffer from this, and the code that resided in the OnLoad() event was not coded to take account for only updates or create.
I came across this post: , dealing with CRM 3.0.
As a result, I customized the fields that were read only to normal. I then added this code to my OnLoad() event, to the Opportunity form, to disable the fields.
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
//Adjust the display of the calculated fields to inline
//change field to enable
crmForm.all.CRMFIELD1.Disabled = true; //false
crmForm.all. CRMFIELD2.Disabled = true; //false
Then on each field that contains a variable to calculate these fields I added the following to the OnChange() event:
//change field to enable, so values can be saved
crmForm.all.CRMFIELD1.Disabled = false; //true
//Place your code below
//Disable Field after update
crmForm.all.CRMFIELD1.Disabled = true; //false
Then on the OnSave() event for the form, I then enabled the fields for saving.
Comments
Post a Comment