We help IT Professionals succeed at work.

Calculated money values above 1000 generate 'NaN'

twardnw
twardnw asked
on
Medium Priority
1,128 Views
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.
Comment
Watch Question

Commented:
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?
http://www.experts-exchange.com/Microsoft/Applications/Microsoft_Dynamics/Q_24135815.html

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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

Commented:
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.

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.