Doing Math in Microsoft CRM aka Calculated Fields

This is a question I get about once a week and got tired of typing up the same email over and over again. J Doing Math in Microsoft CRM using Jscript is mind numbingly easy. If you can do an Excel (Or VisiCalc) math equation, then you can do one in Microsoft CRM.

How you ask? Insert a Jscript on the field that you want the math done in. (So if you want Annual Income plus Alimony, this is how you could do it… And this is in case you can forget about the Anniversary date or month. J)

So you will have three fields:

1. Annual Income – new_AnnualIncome

2. Annual Alimony – new_AnnualAlimony

3. Total Annual Income – new_totalannualincome

On the Total Annual Income, put a OnChange script that looks a little like this:

crmForm.all.new_totalannualincome.DataValue = crmForm.all.new_annualincome.DataValue + crmForm.all.new_annualalimony.DataValue;

Under normal circumstances CRM will not include disabled fields when saving forms even when the data has been changed. We can, however, force CRM to include this field by using the ForceSubmit property as seen below:

 crmForm.all.new_totalannualincome.ForceSubmit = true;

I would disable the field. Then on the other two fields, paste this Jscript into their OnChange event:


So the math you can do includes: