Want to Setup SalesforceDX (SFDX) for Sandbox, Developer and Production Orgs ?
Step 1) Install Salesforce CLI (SFDX).
Step 2) Install VSCode and Salesforce Extension for VSCode. Check our last post for same.
Step 3) Add "Salesforce CLI Integration" Extension in VSCode.
Step 3) Create SFDX Project.
Click Ctrl +Shift + P and then type SFDX . Then select "SFDX: Create Project with Manifest" option
After that Enter the project Name and select Folder where you want to save your project.
Step 4) Authenticate your Sandbox/Developer org.
- 4.1 ) If you want to authenticate your sandbox then please change URL in below file "sfdx-project.json"
For Sandbox :-
"sfdcLoginUrl": "https://test.salesforce.com",
For production or Developer org
"sfdcLoginUrl": "https://login.salesforce.com",
- 4.2 ) Then Authorize your org
or you can execute below command for same if you are using CMD.
sfdx force:auth:web:login --setalias MyDevOrg --setdefaultusername
NOTE:- VSCode will also execute the above command automatically in Salesforce CLI Terminal
Step 5) Update your package.xml file.
Open Package.xml file from Manifest folder. Then Modify your Package.xml file to add and remove component.
Step 6) Retrieve Component
Click on Package.xml and select "SFDX: Retrieve This Source from Org" option.
or you can execute below command for same if you are using CMD.
sfdx force:source:retrieve --manifest d:\Amit\MyDevOrg\manifest\package.xml
NOTE:- VSCode will also execute the above command automatically in Salesforce CLI Terminal like below
Step 7) Deploy changes in Org.
Now do your changes in VSCode and then select the file which you want to deploy in your org. Then Right click on VsCode and select "SFDC: Deploy This Source to Org" option for deployment.
or you can execute below command for same if you are using CMD.
sfdx force:source:deploy --json --loglevel fatal --sourcepath
d:\Amit\MyDevOrg\force-app\main\default\classes\AccContExtTest.cls
NOTE:- VSCode will also execute the above command automatically in Terminal
Recently we did session in "Apex Hours" on "SalesforceDX for Non-Scratch Org" with Mohith Shrivastava. Thanks Mohith for a great session. Here is recording for same session
Please check this recording if you want to learn how to setup VsCode for Salesforce.
Hi Amit,
ReplyDeleteI have one question
I have created two scratch orgs
1. scratchOrg1
2. scratchOrg2
and now I wanted to switch between these scratch orgs, what should I use or how will I make sure that all my development move to one selected org.
Thanks,
Puneet
You can follow below step for non scratch org
Delete1) Download the all component in vscode which you want to deploy in other org (Use SFDX: Retrieve This Source from Org)
2) Then Authenticate your 2nd org with "SFDX: Authorize an Org" command
3) Then deploy the changes with "SFDC: Deploy This Source to Org"
Hi Amit,
ReplyDeleteI have same question in mind as Puneet mentioned above.
Thanks,
Krishna
let me know if you need more detail
DeleteHi Amit - Appreciate for this detailed post
ReplyDeleteThanks for your feedback
DeleteMy Name is Sunil
ReplyDeleteThanks for this info.
ReplyDeleteHi Amit,
ReplyDeletePlease help me for following vs code deploy error:
c:\Users\rohit_mishra1\Desktop\forceApp\HelloWorldLightningWebComponent\force-app\main\default --json --loglevel fatal ended with exit code 1
Thank you for this, it is a very helpful guide for a potentially confusing process!
ReplyDeleteHi Amit,
ReplyDeleteAfter running the below command i am getting error.
command:
sfdx force:source:retrieve --manifest d:\Amit\MyDevOrg\manifest\package.xml
error:
ERROR running force:source:retrieve: Invalid or unsupported zip format. No END header found
i changed the file location to my local path for the above command.
Appriciate your help.
Thanks
me too have that problem
DeleteHi Amit,
ReplyDeleteI am getting Authorization failed http://localhost:1717/OauthRedirect?error=OAUTH_APP_BLOCKED&error_description=this+app+is+blocked+by+admin&state=e7f8c2973eae
when i executing the SFDX:Authorize Sandbox ?
Can you help
Hi Amit,
ReplyDeleteFor DX with Non Scratch Orgs, the DX structure is only in VS code and package xml structure in VS Code is similar to traditional format - correct? We are trying to do GitHub integration with Non Scratch Org using DX. Do we keep a copy of the DX format as 'Master' in GitHub for identifying the "Diff"? Also by not using Scratch Org, are the DX commands still able to pull the changes and all dependencies like in Scratch Org?
Hi Amit does this also work with normal sandbox?
ReplyDeleteHI Amit,
ReplyDeletei have followed your instructions but i am not able to retrive the data from org(sandbox). Getting below the error while trying to retriving the data.
18:49:49.47 sfdx force:source:retrieve --manifest c:\Users\612311\Documents\testprjct\testproject\manifest\package.xml
ERROR running force:source:retrieve: Parse error in file C:\Users\612311\.sfdx\stash.json on line 1
18:49:56.550 sfdx force:source:retrieve --manifest c:\Users\612311\Documents\testprjct\testproject\manifest\package.xml
ended with exit code 1
Please help me on this.
Thanks in advance!!
Raju
9030709188
Hello Raju,
DeleteDid you able to sort this out? I faced the same error but with the command. sfdx force:source:push And it was working fine two days ago. Just started facing this issue.
Just delete stash.json, you should be fine, it gets generated by sfdx cli command automatically. This happens when previous sfdx command failed or corrupted.
DeleteF6C1D
ReplyDeleteAmiclear