4

I am still quite new to sfdx, so perhaps I am missing some important step but basically this are the steps I follow to create a project in VS CODE using the SFDX extension:

I start by selecting the option:

  1. sfdx:create project with manifest
  2. sfdx: authorize org (I did not create any alias, I just hit enter a couple of times to log in from browser).

Everything seems to be working fine, I created this for a sandbox and a couple more for some dev orgs.

For the last few days I notice that my project wasn't refreshing when i right click in a file and I was selecting retrieve source from org, I was getting the success message:

SFDX: Retrive source from org successfully run.

But the file was not updating to the latest version

So I proceed to delete all the folders defined in my metadata, the ones that will appear inside the white box.

Folders deleted

And it was really interesting that despite of been in my sandbox project in VS Code, after I retrieve source in manifest org it brought my developer account org.

Is there a setup that I need to add to avoid this as this could be so dangerous if I am working with similar sandboxes?

3

The VSCode extension from salesforce uses Salesforce CLI under the hood to manage the authorization .

CLI provides ability for you to authorize as many as orgs you would like with an option to set default org at the project level and also you can set default globally if you would like .

Below are some key points to understand

  1. Your project directory has hidden directory .sfdx with a file sfdx-config.json.This file holds the default username .

  2. You can also find a similar folder in your Operating system HOME directory that holds few more files . It will have file for every org you logged in json format with access token and refresh tokens to manage auth .

Now when you say you authorized it without alias thats not good practice .I would recommend when you authorize your org set a unique alias for each org and also select one of them as default alias .

Your vscode editor will show you default alias in the footer ,(you can even click and log into the org from there )

enter image description here

Salesforce is building capability to allow you to switch between orgs easily that will make life simpler .You can switch today easily by running sfdx force:config:set defaultusername=<alias> in terminal .

Always make sure to set a defaultusername for your project so that way you know which org your local project saves and retrieves files .

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.