8

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?

3 Answers 3

13

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.

1
  • I might add that to change the corporate, one must set the new corporate currency before unsetting the old. Commented Sep 11, 2018 at 8:09
1

This is now supported. I just had to do this same thing on a scratch org, solved it by using to export

sf data export tree --query "SELECT Id, IsoCode, ConversionRate, DecimalPlaces, IsActive, IsCorporate FROM CurrencyType" --target-org prodOrg --output-dir data 

And this to import in the scratch org

sf data import tree --files data/CurrencyType.json --target-org scratchOrgAlias 
0

The metadata API doesn't support currency exchange rates, so you can't automatically set up multiple currencies. This is still, unfortunately, a manual process.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.