Fun With Currencies

I’ve updated the currency on my record, but Currency field values didn’t change! Huh?!?

The Scenario

We have an Opportunity set to Currency of ‘USD’ with an Amount of ‘$20,000’. The Currency is updated to ‘EUR’ and our Amount remains at ‘20,000’ but is now ‘€20000’. As the Currency Exchange Rate is not 1:1, we may have expected that the Amount field would adjust based on the change in Currency. Why doesn’t it?


The behavior is actually pretty straightforward once we see it in action, but I didn’t see it documented anywhere…

  • If the Currency type field is part of the record when the CurrencyIsoCode is changed, then the Currency type field value WILL NOT change.
  • If the CurrencyIsoCode field is changed, where Currency type fields are NOT present, then the Currency field values WILL offset based on the exchange rate.

For the examples that follow, we have EUR set up with an exchange rate of .95 against USD.

Example of these Rules in Action

On the Opportunity, we have CurrencyIsoCode set to USD, and the Amount field at $20,000.

Updating the CurrencyIsoCode to EUR, the Amount field remains at 20,000, but the Currency changes to € (EUR). As we can see, there was no exchange rate applied to the Amount value field, so we’ve actually increased the Amount value ‘by accident’ here.

If we make the same update through Apex, and have both the CurrencyIsoCode and the Amount in the record when saving (Apex class, Anonymous Apex, or Query Editor).

Opportunity o = [SELECT Id, CurrencyIsoCode, Amount from Opportunity where Id = '0065e000004Oq2TAAS'];
o.CurrencyIsoCode = 'EUR';
update o;

Then we end up with the same result, which may not be what we want.

If we do the same thing, but do not include the Currency type Amount field…

Opportunity o = [SELECT Id, CurrencyIsoCode from Opportunity where Id = '0065e000004Oq2TAAS'];
o.CurrencyIsoCode = 'EUR';
update o;

Now we see that the exchange rate has been automatically applied USD => EUR for the Amount field.

So the upshot here is that if we’re going to be dealing with changing CurrencyIsoCode, and we also have Currency type fields in our record(s) for DML, we’ll need to account for the exchange rate offset.

Wrapping Up

I can picture business scenarios where we might want the Currency type values to remain the same when CurrencyIsoCode is changed, and can imagine others where we’d want the exchange rate applied on the back end. That said, I found the behavior itself very curious, and without knowing how it works, it’s difficult to design and build in a way that produces the desired result!

Hopefully this explanation saved you some confusion and/or grief. Let me know if you have some additional information to add, as the documentation in this area seems to be lacking!

Leave a Reply

Your email address will not be published. Required fields are marked *