Salesforce DX Learning

Installation Required Software in Windows 

        1. Java SDK and JRE
        2. GIT Repository
        3. Salesforce CLI
        4. Visual Studio Code

 Configuration Required 
       Add Window's Environment Variable Path 

         1.C:\Program Files\Java\jdk1.8.0_144\bin;
         2.C:\Users\dineshkumar.r\AppData\Roaming\npm;
         3.C:\Program Files\Salesforce CLI\bin

 Install Required Extantion in  Visual Studio Code
          Open VS-Code Install the Following Extention for Salesforce

          1.Salesforce CLI Integration
          2.Apex
          3.Apex Interactive Debugger
          4.Apex Replay Debugger
          5.Aura Components
          6.Salesforce Extension Pack
          7.Visualforce

Install Salesforce DX in Visual Studio Code
          Open the Terminal in Visual Studio Code  and  Type following Commend
     
      []  1.  Npm instal - global SFDX-CLI
            (Installing SFDX CLI to Node Package Manager Globally )

      [] 2.  SFDX Version
             (Check Current Version )

       [] 3. SFDX Update
             (Update to Current Version )

       [] 4. SFDX plugin -- core


Enable Dev Hub In Salesforce Org
           Login into Salesforce Org and search DevHub in Quick Find
            or Navigate to Development - > DevHub
            Enable Dev Hub
           Notes: Once  you enable you can't disable Dev Hub


Login Salesforce Org from Visual Studio Code Terminal 
   
         Open the Terminal Window in Visual Studio Code and Type following Commend
 
     []   sfdx force:auth:web:login -d -a MyDevOrg727
           ( "-d" stand for Set as default devhub user
              "-a" stand for set a alias name  ) we can use below alternatively
    []   sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-hub-org 
          if you are going to login in Sandbox Org we can user below commend
     []   sfdx force:auth:web:login -d -a MyDevOrg727 --instanceurl https://test.salesforce.com
                                         OR
   [] sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-hub-org --instanceurl https://test.salesforce.com

 
Logout Salesforce org from Visual Studio Code Terminal

              logout from a specific user account 
    [] sfdx force:auth:logout --targetusername dineshkumar727@myorg.com
                                or
              logout from all the user account
    [] sfdx force:auth:logout --all

Create a Salesforce Scratch Org 
      Create a folder in your computer and create a json file inside the folder 
  Add below Json text Sample in your file based your requirment for Scratch org

  {
"orgName": "Dreamhouse",
"edition": "Developer",
"hasSampleData": "false",
"settings": {
"orgPreferenceSettings": {
"s1DesktopEnabled": true,
"selfSetPasswordInApi": true,
"s1EncryptedStoragePref2": false
}
}
}
  here Json file name is  project_scratch_dev.JSON

  locoate the Terminal to file location and type following commend 

  [] sfdx force:org:create -s -f project_scratch_dev.JSON -a "MyScratchOrg727"


Open the Scratch Org
 
     type following commend to open the scratch org 
 []  sfdx force:org:open 
      
      type following commend to open the specific scratch org
  [] sfdx force:org:open -u myscratchOrg727



Create a Project
        
     1. Create a Project using VisualStudio code Command Pallet 

     Select  View in Toolbar then select Command Pallet from the list or Use the ShortCut Key                   Ctr+Shift+P
      In Command Pallet  
             1. Select the Command  > SFDX: Create Project
             2. Enter the Project Name
             3. Select the Folder to Keep your Project

   2. Create a Project using Sfdx commend from a Terminal window

      [] sfdx force:project:create --projectname  MyNewProject728 -d  Myapp
          (-d stand for default directory name or Folder name where you want to keep your project)


Retrieve the Package to your Project from Developer Org / Sandbox Org

      create package in the salesforce Org and use below code to retrive   

      [] sfdx force:mdapi:retrieve -s -r -/temp -u dineshkumar727@myorg.com -p myPackage
    Package will be downloaded as a compressed Zip file in the Temp folder

     retrieve a single apex class
      [] sfdx force:source:retrieve -m ApexClass:APTS_TC_EMEAPricingCallback
      it will store to force-app\main\default\classes

     Create a package.xml in your local drive and use below code
Package.xml as below
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>APTS_PricingCallBack</members>
        <name>ApexClass</name>
    </types>
    <version>47.0</version>
</Package>

    [] sfdx force:source:retrieve -x temp/package.xml

Convert the Package to your project
        Extract all the file from the Zip and placed in the same Temp Folder .

     []  sfdx force:mdapi:covert -r /temp


Pull the Source to the Project from Scratch 
      
    [] sfdx force:source:pull -u myscratch1


Push the Source from the Project to Scratch

   [] sfdx force:source:push -u myscratch1


  Deploy the project to Developer Org/ Sandbox Org
  
  [] sfdx force:mdapi:deploy -d mdapioutput_dir/ -u "sandbox_username" -l RunSpecifiedTests -r test1,test2,test3,test4 

  How to Retrieve the Source from Dev or Sandbox Org

 Needs to create a Pacakge .xml file with source of content that we need to retrive.

   [] sfdx force:source:retrive -a mytest -r Package.xml.

Comments

Popular posts from this blog

What is Getter and Setter Method in VF page