Link to home
Start Free TrialLog in
Avatar of SoftDesignServices
SoftDesignServicesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Calculated fields in MS Dynamics CRM 4.0

Hi all,
I have created an attribute in Opportunity entity "Total" which should display the total of "Actual Revenue" and "Estimated Revenue".

I have put the following script in the onChange event of "Total" : crmForm.all.new_total.DataValue = crmForm.all.estimatedvalue.DataValue + crmForm.all.actualvalue.DataValue;

and the script : new_total_onchange0()
in the OnChange event of "Actual Revenue" and "Estimated Revenue" fields.

This does not seem to work for me. Can you please provide you suggestions on this. This is an urgent requirement.

Avatar of Aftab_Khateeb
Aftab_Khateeb
Flag of Australia image

Onchange event would occur only when you change any value in a field, I hope you are not updating any value in "Total" field and hence you are not seeing the updated value.

Add this code in "OnSave" event of the form and then check out the "Total" field, after saving the form with both Actual and estimated revenue fields filled in. you can try with Save or Save and close option as well (then reopen the form)

Also check if the name fields of the estimated revenue and acutal revenue are corrent in attribute list of the entity, i dont hv a CRM to check the exact names of the fields, if they are fine then its all good and just try above mentioned event of the opportunity form (Onsave event).

Let me know how u go
ASKER CERTIFIED SOLUTION
Avatar of Feridun Kadir
Feridun Kadir
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SoftDesignServices

ASKER

Please help me find out the problem
My comment of 04/05/10 at 3.25pm answers your question.
These solutions do not seem to work for me. Is there any other way out?
I tested the solution before posting.  COuld you give some more information as to what happens with my suggested solution?

Also, if do try my solution you need to remove any of the existing scripts for the fields in question.

I'm not around until tomorrow now - so I won't be able to reply any more today.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is working for me now.
Great. What did you do to get it working?
1. Created a new attribute new_expectedrevenue
2. Added the attribute to the form
3. Added the code below to the onChange events of each of the following attributes – one off revenue, annualised revenue and closeprobability

 crmForm.all.new_expectedrevenue.DataValue =((crmForm.all.estimatedvalue.DataValue + crmForm.all.new_annualisedrevenue.DataValue) * crmForm.all.closeprobability.DataValue )/100 ;

crmForm.all.new_expectedrevenue.ForceSubmit = true;

This code works for me and I got the desired output.
Thank you all for your help.

Several comments and ideas were provided in response to the question. SoftDesignServices responses acknowledge that the comments provided assistance. Therefore, some or all of the 500 points should be awarded.
I recommend option 3. Award points to feridun (that is me) http:#a32632789 and Aftab_Khateeb http:#a32632760 equally.

Since our recommendations helped but did not solve entirely SoftDesignServices query, I propose 125 points to each of feridun and Aftab_Khateeb with the remaining 250 points refunded back.
All,
 
Following an 'Objection' by feridun (at https://www.experts-exchange.com/questions/27016925/11-May-11-17-Automated-Request-for-Review-Objection-to-Accept-Q-26158347.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
 
At this point I am going to re-start the auto-close procedure.
 
Thank you,
 
_alias99
Community Support Moderator