locked
Calculate percentage of a field RRS feed

  • Question

  • I have a field called Income. I have another field called Amount. I have a third field called percent.

    If the value of Income is under 20,000 then I want to automatically calculate 15% of the value of field Amount and I want this 15% value to be put into the third field called Percent.

    Someone suggested to me to carry out these calculations using workflow, but does anyone know any other way to do these kind of calculations?

    Thanks.

    Thursday, May 10, 2012 3:13 PM

Answers

  • Hi,

    Javascript can do this easily, it should be something like below, you could need to do some changes, you can use this code onchange or your income field

    var Value=Xrm.Page.getAttribute(FieldName).getValue();

    var Amount=Xrm.Page.getAttribute(FieldName).getValue();

    if(Value<=20000)

    {

    var Per=(Amount*15)/100;

    Xrm.Page.getAttribute(FieldName).setValue(Per);

    }


    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, May 10, 2012 3:25 PM
    Moderator

All replies

  • Hi,

    Javascript can do this easily, it should be something like below, you could need to do some changes, you can use this code onchange or your income field

    var Value=Xrm.Page.getAttribute(FieldName).getValue();

    var Amount=Xrm.Page.getAttribute(FieldName).getValue();

    if(Value<=20000)

    {

    var Per=(Amount*15)/100;

    Xrm.Page.getAttribute(FieldName).setValue(Per);

    }


    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, May 10, 2012 3:25 PM
    Moderator
  • Thanks Mahender.
    Friday, May 11, 2012 8:56 AM