I'm writing SalesforceDX unit tests that need to use either USD or EUR in Account.currencyIsoCode. So I created a scratch org from this project-scratch-def.json configuration that specifies the MultiCurrency feature:

  "country": "US",
  "edition": "Developer",
  "features": ["MultiCurrency"],
  "orgPreferences": {
    "enabled": [
    "disabled": []
  "orgName": "MyOrg",
  "adminEmail": "admin@my.org"

Running a test fails with this error:

System.DmlException: Insert failed. First exception on row 0;
invalid currency code: EUR: [CurrencyIsoCode]

Turns out that creating an org with the feature MultiCurrency only has one currency (USD) configured, which can be checked in the developer console with:

SELECT IsoCode FROM CurrencyType

I googled, but couldn't find a way to configure the active currencies in the project-scratch-dev.json, so I figured I would just insert them in the tests themselves, like so:

static testMethod void testEuros() {
  List<CurrencyType> euros = [select IsoCode from CurrencyType where IsoCode = 'EUR'];

  if (euros.size() == 0) {
    CurrencyType euro = new CurrencyType();
    euro.IsoCode = 'EUR';
    euro.IsActive = true;
    euro.IsCorporate = false;
    euro.DecimalPlaces = 2;
    euro.ConversionRate = 1.0;
    insert euro;

  Account acc = new Account();
  acc.Name = 'TestAccount';
  acc.CurrencyIsoCode = 'EUR';
  insert acc;

But this attempt is cut short by sfdx force:source:push refusing to push the source with the following error:

DML operation Insert not allowed on CurrencyType

So the question is... How does one properly configure currencies in a multi-currency scratch org? Preferably in the project-scratch-def.json, but definitely without opening the org and making manual changes, that is.


Neither DML nor Metadata API support Currency (Exchange) Inserts.

The tree/bulk api does, though, see this answer for a programmatic way to enable different currencies in a scratch org:

How to prep scratch org with currencies

| improve this answer | |
  • Perfect! Exactly what I was looking for, thank you! – Patrick Atoon Nov 26 '18 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.