[SalesForce] How to prep scratch org with currencies

When creating my Scratch org, I've added the MultiCurrency feature, and that works, but I still need to go in manually to add the currencies and set the company currency. Is it possible to to this via CLI, so scratch orgs can be more scripted?

Best Answer

Yes, you can insert currencies and change the corporate currency via the API. A quick way of doing this is sfdx force:data:tree:import -f CurrencyTypes.json where CurrencyTypes.json contains the following:

{
  "records": [
    {
      "attributes": {
        "type": "CurrencyType",
        "referenceId": "ref1"
      },
      "IsoCode": "INR",
      "DecimalPlaces": 2,
      "ConversionRate": 1.5,
      "IsActive":true,
      "IsCorporate": true
    }
  ]
}

Importing this into my scratch org, which was created with a default currency of GBP, (my scratch definition has a country of "GB"), resulted in my corporate currency becoming INR, and GBP being updated with an appropriate conversion rate to the corporate currency.