Calculated money values above 1000 generate 'NaN'

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.
Who is Participating?
crm_infoConnect With a Mentor 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?

twardnwAuthor 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.
twardnwAuthor 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.
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.