Business Rules, formula, sum 3 fields?

This question is answered

Hello,

I have 4 fields in my form (opps) I need to sum 3 of them and set the total in the 4 field. Is there a way to do this?

So far I just see using a hidden field to keep a first sum between 1st and 2nd fields and then sum the hidden field with my 3rd field. Or try a sync workflow...

Verified Answer
  • Hi,

    You can do the sum using JavaScript inside the OnChange events for the three fields.

    Something like this example:

    function SumValues() {

    var f1 = Xrm.Page.getAttribute("new_field1").getValue();

    var f2 = Xrm.Page.getAttribute("new_field2").getValue();

    var f3 = Xrm.Page.getAttribute("new_field3").getValue();

    var total = f1 + f2 + f3;

    Xrm.Page.getAttribute("new_total").setValue(total);

    }

All Replies
  • Hi,

    You can do the sum using JavaScript inside the OnChange events for the three fields.

    Something like this example:

    function SumValues() {

    var f1 = Xrm.Page.getAttribute("new_field1").getValue();

    var f2 = Xrm.Page.getAttribute("new_field2").getValue();

    var f3 = Xrm.Page.getAttribute("new_field3").getValue();

    var total = f1 + f2 + f3;

    Xrm.Page.getAttribute("new_total").setValue(total);

    }

  • Hey thanks Guido!

    I didn't want to do JavaScript but I guess that's the "cleanest" way.

    thanks!