Why my money fields get updated all the time?

Hello everyone,

I wanted to write this quick article to let you know what i just figured out with my colleague.
For a long time, we had an issue about the update of any information on an opportunity (closed or not) because of the exchange rate changes.

You have a default currency on your CRM (€), when you create an opportunity in an other currency ($), the moneyfield_base gets updated automatically with the conversion.

For a long time, I tried to keep the original exchange rate while I needed to update some random informations. But unfortunately, the fields in $ were always updated to the latest exchange rate value which was breaking all relevant informations about the money.

Let's see how I was doing my update (sample) :

Entity opportunity = service.Retrieve("opportunity", new Guid("C9C753AA-62F1-E711-A953-000D3A2BB81E"), new ColumnSet(true));  
opportunity["description"] = "Description updated";  

This won't help, unfortunately, it's updating the money fields even if i updated only the Description field as you can see.

Now that I found out the reason, it seems really basic and "stupid".
If we go back to the code above, while i'm retrieving the opportunity record, i'm using new ColumnSet(true) : this means, that i will retrieve all entity fields.
Even if with the code i update only the description, during the service.Update the CRM receives everything and update all fields retrieved upfront.

If now we use this code :

Entity opportunity = service.Retrieve("opportunity", new Guid("C9C753AA-62F1-E711-A953-000D3A2BB81E"), new ColumnSet("description"));  
opportunity["description"] = "Description updated";  

Here is the result in the CRM :

Only the description was modified, nothing about the money fields and the currency.

Success, it was that simple !

Basically, the money fields will be updated only if there is a change/update to the following fields :

  • Status of the record
  • One money fields (trigger update for the others too)

I guess it's good to know and can help to keep your data update to date because before you were afraid of updating the money fields :).

Happy CRM'in,


Read more posts by this author.