locked
Creating a calculation field in Microsoft CRM Online RRS feed

  • Question

  • Hi,

    I have created a report related to our sales opportunities. I noticed in one of the out-of-box, sales pipeline, reports that there is a column that displays a calculation on estimated revenue and the weighted revenue based off of the probability of the opportunity.

    What I would like to do is add a field in our opportuntiy record that makes the calculation in the opportunity itself. Although I don't know anything about xml or javascript coding. Are there any tutorials or pre-built coding that I could use for something like this?


    This is the script that I put in the Customizations, Events, OnChange

    var multiply = crmForm.all.EstimatedRevenue.DataValue * crmForm.all.Probability.DataValue;

    crmForm.all.ForecastedRevenue.DataValue = total;

    Will this even work?

    • Moved by Xiaopeng Wu Tuesday, March 8, 2011 11:38 PM Forum consolidation (From:CRM Online)
    Wednesday, April 8, 2009 9:07 PM

Answers

All replies

  • The jscript looks valid.

    There are a couple places to check out to learn about jscript.
    http://www.w3schools.com/ Great site to learn about jscript and such.

    Next, you'll want to spend some time in the CRM SDK to learn about client side programming with jscript and the document object model for CRM

    Download at
    http://www.microsoft.com/downloads/thankyou.aspx?familyId=82e632a7-faf9-41e0-8ec1-a2662aae9dfb&displayLang=en

    -cheers
    jonw
    Thursday, April 9, 2009 2:14 PM
  • Thanks for replying. I do know about w3schools it is a great website.

    Also, I have already downloaded the CRM SDK and I haven't found it very useful. I can’t ever seem to find any information on the topics I am looking for.

     

    I was able to figure out the programming to make my calculation, now I just want to know if it is possible to create an if/then statement in my onChange event so I don’t have to use a workflow because it is conflicting with onChange Script.


    var value1 = crmForm.all.your_field1.DataValue;
    var value2 = crmForm.all.your_field2.DataValue;

    value1 = (value1 == null) ? 0 : value1;
    value2 = (value2 == null) ? 0 : value2;

    crmForm.all.your_sum.DataValue = value1 * value2 ;

    Thursday, April 9, 2009 3:26 PM
  • Yes, you can use if/then statements in the CRM Online form events.

    Reference:
    http://www.w3schools.com/js/js_if_else.asp




    Example:

    if (value1.value == null) {
    value1.value = 0;
    }
    else {
    // this is not needed if you want to keep value1.value the same
    }

     


    http://www.workopia.com/Links.htm
    Thursday, April 9, 2009 6:38 PM
    Moderator