4

I am using SFDX to develop an app for German users. My tests assume the test-running users has EURO as default currency. Therefore my tests fail as the admin user auto-created with a scratch org uses US dollars.

Is there any way I can modify this admin user?

I know that I can create additional scratch org users using

sfdx force:user:create --definitionfile config/user-def.json

but making one of those additional users the admin that logs in on force:org:open or runs tests seemed to be really complicated.

1
  • 1
    Could you use { "country": "DE" } as part of your scratch-def.json? That sets the company country, and I think it also implies defaults for all the users
    – Aidan
    Commented Oct 18, 2018 at 14:08

2 Answers 2

11

We actually had the same use case, but for the user language.

You have 2 options to do this:
Use a standard sfdx command to update the user:

sfdx force:data:record:update -s User -w "Name='User User'" -v "LanguageLocaleKey=en_US"

This works fine, but assume that Salesforce will never change the default user name (User User) so far.

To be sure our update won't break, we built a custom sfdx command to do this. It's almost the same thing, except that it's using the sfdx core library under the hood to get the created username. This way, the command will always work even if the default user name changes:

sfdx texei:user:update -v "DefaultCurrencyIsoCode=EUR"

You can find the plugin, as well as installation documentation here.

1

It is possible to grab the user Id using jq library and then use record update command with -i switch flag to update the auto-generated user like following, without using any custom sfdx plugins

sfdx force:data:record:update -s User -i $(sfdx force:user:display --json | jq '.result.id' -r)   -v "LanguageLocaleKey=en_US"  

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .