I've created two workflows that count the number of leads and the number of a custom entity called Legal cases. I would like to come up with a ratio for reporting purposes that calculates legal cases/leads. The workflow updates two fields on the forms (leads and cases) every time one of the entity is created. I tried to use the following code:
function calculate()
{
var val1 = Xrm.Page.entity.attributes.get['getlead_casecounters'].getValue();
var val2 = Xrm.Page.entity.attributes.get['getlead_leadcounter'].getValue();
if(val1==null)return;
if(val2==null)return;
var result = val1 / val2;
Xrm.Page.entity.attributes.get['getlead_casetoleadratio'].setValue(result);
}
The problem is that the casetoleadratio field doesn't appear to update. Any thoughts or recommendations?