Imagine you're working on 2-3 Salesforce projects each with a different target Orgs (sandboxes for different companies).

You're actively working on project 1 (coding, running tests, deploy source to the org etc) and in parallel to this, you need to make a couple of tweaks to project 2 and project 3 during the same time period.

Therefore you have 3 instances of Visual Studio Code open.

I realise I could run this command to tell SFDX which org is the default

sfdx force:config:set defaultusername=ALIAS_NAME


sfdx force:config:set [email protected]


Is there a setting in the project-scratch-def.json that will tell Visual Studio Code which Org it should run the Salesforce DX against?

1 Answer 1


When you run sfdx force:config:set the value is set at the project level unless you use the -g flag. So running sfdx force:config:set defaultusername=alias in a project folder will make that the default org for the project and the commands that you run in vscode will respect that.

  • 1
    Thanks. So let me get this straight, I can set the defaultusername on a per folder basis?
    – Robs
    Sep 8, 2018 at 13:06
  • 1
    That's correct. When you set a config value (including defaultusername) without the -g flag, the value is stored in the .sfdx\sfdx-config.json file in your project directory and used only for that project. Sep 8, 2018 at 13:12
  • @JohnTowers where is that information stored? I can't find any reference to my devhub org in any file. Let's say I want to switch my current project directory to point to another debhub/scratch org May 6, 2020 at 10:41
  • The project config is stored in [project root]/.sfdx/sfdx-config.json'. There should be a defaultusername` property that has the username or alias for the current default org. If you used -g to set the default the value is stored in the .sfdx/sfdx-config.json in your home folder. If you want to change the just the current project for another org you should run the command in my answer. That will update the config file and has the added benefit of validating the username/alias you pass in. You can technically edit the file directly but that bypasses the validation and is prone to error. May 7, 2020 at 15:39

You must log in to answer this question.

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