Search code examples
dynamics-crmdynamics-crm-onlinedynamics-crm-2015

How to force exchange rate in sales order


We are doing a migration of sales orders from an old system to Dynamics CRM online. In the old system we have one amount in one currency and other amount in base currency(USD). The ratio between those two is the exchange rate that was valid in time the original record was created.

Is there a way how can we transfer old orders so that the exchange rate stays the same? Currently it gets overwritten by the current exchange rate for given currency.


Solution

  • For any currency attribute in CRM you can unfortunately not set the _base currency or exchangerate directly. Otherwise that would be the easiest solution. As a work-around you can instead use the following solution:

    As mentioned here, CRM supports registering plugins on the RetrieveExchangeRate message. Normally the exchange rate is taken from the transaction currency, but you can override that. You could register a plugin on this message which returns the needed exchange rate for the specific record. How you find the correct exchange rate would depend on your exact situation, but one way could be to first store all the historical exchange rates in a custom entity. You would then subsequently run your import of data.

    In your plugin running on RetrieveExchangeRate you would look up the relevant exchange rate from the custom entity and return it, resulting in the imported data having the correct exchange rates.