crmForm.all.new_fieldc.DataValue = crmForm.all.new_fielda.DataValue + crmForm.all.new_fieldb.DataValue;
if((Xrm.Page.getAttribute(sFieldA).getValue() != null)||(Xrm.Page.getAttribute(sFieldB).getValue() != null))
Xrm.Page.getAttribute(sResultField).setValue(Xrm.Page.getAttribute(sFieldA).getValue() + Xrm.Page.getAttribute(sFieldB).getValue());
Save and publish the webresource. Now you can use this function on any CRM form and call it as many times as you like. To do so, first add the webresource as a library to the form. When included, go to the properties of a field and set the OnChange event by selecting the library, set the name of the function and add the fieldnames to be used in the function as a comma separated list of parameters that will be passed to the function.
Here’s an example on how to do so:
The catch: make sure that if you change an existing function for one specific requirement that there’s no other part within your Microsoft Dynamics CRM solution that breaks.