Calculated money values above 1000 generate 'NaN'

Posted on 2009-02-16
Last Modified: 2012-05-06
Overall goal : calculate a 'weighted revenue' for an opportunity based on the estimated revenue and a probability percent. Probability is a picklist of % values, with an onChange script to generate the weighted value.

With any estimated value over $1000 (which CRM reformats as 1,000.00), the weighted value changes to 'NaN'. Here is one line of my script to calculate this value:

crmForm.all.new_weight.value = 0.5 * crmForm.all.estimatedvalue.value;

if I change to using .DataValue, no amount is calculated for the weighted value.
Question by:twardnw
    LVL 10

    Accepted Solution

    I'm not sure I'm completely understanding your question.  Here are a few thoughts to consider:

    (1) I believe the correct calculation is:
    crmForm.all.new_weight.DataValue = 0.5 * crmForm.all.estimatedvalue.DataValue;

    (2) Estimated Value is automatically calculated in CRM and stored in the estimatedvalue field.  Rather than created another estimated revenue field, you may just want to update the probability field.  This way the included sales pipeline reports will work a little better.  Just a thought.

    (3) Is it possible that you did not add the ForceSubmit method?  If you update a read only field, you need to use ForceSubmit to force the field to be written back to the DB when the form is saved.  Example:
    crmForm.all.fieldname.ForceSubmit = True;

    (4) How is this different than the question I answered for you the other day?


    Author Comment

    1) using :
    crmForm.all.new_weight.DataValue = 0.5 * crmForm.all.estimatedvalue.DataValue;
    doesn't generate anything at all, the new_weight attribute does not change

    2) we are using only user-entered info for estimated value

    3) field is not r/o

    4) That was asking how to have the percentage on the form to use for the calculation, this is asking the exact syntax on the calculation. I closed that one before I realized it wasn't working, I didn't include any values over 1000 when I tested, salesperson pointed it out to me later.

    Author Comment

    Ok, had another issue to take care of so I called our MS Partner, I was unaware that CRM was case sensitive. Changing .datavalue to .DataValue solved the issue. You had me in the right direction, just my noobness got in the way. Thanks for your help.
    LVL 10

    Expert Comment

    Ah - makes sense - I've spent more hours frustrated with case sensitivity of JavaScript than I'd like to admit.  Glad it worked out for you.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
    On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now