Saturday, 8 December 2018

SalesforceDX for Non-Scratch Org | SalesforceDX with Sandbox, Developer Orgs | SFDX


SalesforceDX for Non-Scratch Org


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
 Click "CTRL+SHIFT+P" and then select "SFDX: Authorize an Org" and provide Org Alise Name



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.

Thanks,
Amit Chaudhary

Capture.JPG  @amit_sfdc    @ApexHours
  Salesforce Apex Hours 
    #SalesforceApexHours 

14 comments:

  1. Hi Amit,

    I 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

    ReplyDelete
    Replies
    1. You can follow below step for non scratch org
      1) 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"

      Delete
  2. Hi Amit,

    I have same question in mind as Puneet mentioned above.

    Thanks,
    Krishna

    ReplyDelete
  3. Hi Amit - Appreciate for this detailed post

    ReplyDelete
  4. Hi Amit,
    Please 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

    ReplyDelete
  5. Thank you for this, it is a very helpful guide for a potentially confusing process!

    ReplyDelete
  6. Hi Amit,
    After 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

    ReplyDelete
  7. Hi Amit,
    I 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

    ReplyDelete
  8. Hi Amit,
    For 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?

    ReplyDelete