0

I'm working on a Salesforce Lightning App project in Visual Studio Code (w/ Salesforce extension), and when I right click on a file and choose "SFDX: Deploy This Source to Org", it deploys just fine - I can check the changes in my sandbox and they show up.

I thought that where this deploys to is controlled by the value of sdcLoginUrl in the sfdx-project.json file. But when I change that value to another sandbox or even something invalid, it still successfully deploys to my sandbox.

What's going on here?

1

From Salesforce DX Project Configuration, the sfdcLoginUrl parameter is only for auth commands within DX when connecting to your orgs.

The login URL that the auth commands use. If not specified, the default is login.salesforce.com. Override the default value if you want users to authorize to a specific Salesforce instance. For example, if you want to authorize into a sandbox org, set this parameter to test.salesforce.com.

When deploying through the CLI or through clicks within VS Code, it uses the default org set for your project.

In VS Code, you can change this in several ways:

  1. Clicking on the plug icon within the lower left.

enter image description here

  1. Use the config command

sfdx config:set defaultusername=myusername@name.com

  1. Use the command palette with (Ctrl+Shift+P):SFDX: Set a Default Org

If you want to change where you're deploying to within a specific command (and not change the default), there's the --targetusername or -u parameter to pass your username for an org you've already authorized.

sfdx force:source:deploy -u myusername@name.com...


In terms of "orgs", it just represents salesforce instances you've authorized against (production, multiple sandboxes, scratch orgs, etc). When you authorize, you can provide an alias which is considered best practice (see "The Power of Aliasing"). It makes it easier to remember than username.

sfdx auth:web:login -r https://test.salesforce.com -a MyDevSandbox

Instead of remembering your username for that specific sandbox - you can just remember the alias for the commands (ex. MyDevSandbox).

To see all your orgs you've authorized against, you can run the following:

sfdx force:org:list

It'll display your alias, username, and ORG Id.

3
  • So I'm a little confused on what defines an org, or in other words, what's the identifier? I would think it would be a name or url - but from the commands you listed, it seems like it's a username? If so that seems weird, b/c couldn't you have a username associated with more than one org? I think I'm missing something. (btw if I run sfdx force:config:list I get a Name/Value/Location of "defaultusername"/"vscodeOrg"/"Local")
    – jbyrd
    Jul 23 at 18:11
  • 1
    I provided more info in the edit, but usernames are actually unique across your domain. Not to mention, on refresh, each username is appended with your sandbox name. Either way, it's best to give your connection an alias. In your example, vscodeOrg is an alias you gave your connection when you authorized that org - you can reference it with that alias or use the username of the org as well. Jul 23 at 18:22
  • Ah, now I think I got it - thank you!
    – jbyrd
    Jul 23 at 18:34

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.