Recalculate Opportunity and the Page Life Cycle

If you have ever worked with the Dynamics CRM Opportunity, you know that it contains a function to recalculate the opportunity when you have selected System Calculated for the Revenue.

Here are the major areas of focus for this discussion:



When the user presses the Recalculate button on the Ribbon, all of the associated line items will be summaries and that number placed into the Est. Revenue field (estimatedvalue is the internal field name).

It is important to note the order in which this happens because if you have your own JavaScript running on the form, it may not function in the way you expect.

Est. Revenue Field OnChange Event

If you add an OnChange event to the Est. Revenue field, it will not be fired by the Recalculate Opportunity button.  This is because the value of this field is not modified on the form, it is modified in the database.

If you have selected User Provided for the Revenue field, the Est. Revenue field becomes editable and the OnChange event will fire, after someone changes the value and leaves the field.


Recalculate Opportunity Page Life Cycle

When a user clicks the Recalculate Opportunity button, the following events will occur, in this order:

  1. The page will be saved, and the OnSave event will fire.
  2. The database record for the opportunity will be updated with the new Est. Revenue value.
  3. The page is reloaded, which will fire the OnLoad event.


What this means to you

So, what does this mean to your average CRM developer?  Not much unless you need to execute JavaScript on the OnChange of the Est. Revenue field.  If that is the case, and you are using System Calculated as your Revenue type, you need to add your code to the form’s OnLoad event so that it will execute using the most current Est. Revenue value.

Leave a Reply 1 comment