Monday, 29 April 2019

Salesforce DX Understanding



    1. What is Salesforce DX?


    Salesforce DX (Developer Experience) is tool with the ability to consider source code management as source of truth.Source-Driven Development.This allows users to develop and manage Salesforce apps across the entire platform in a more direct, efficient way.
    Build together and deliver continuously is tag line for Salesforce DX.

    Note : For Changeset, Metadata API or Force.com IDE, source of truth is Sandbox.

    Implement  By :
    1. Salesforce CLI [Command Line Interface] / Salesforce Extension for VS Code (Light weight editor) : You can use the CLI or Salesforce Extensions for VS Code to open your scratch org in a browser without logging in.
    2. Scratch Orgs : The scratch org is a source-driven and disposable deployment of Salesforce code and metadata.Facilitate's automated testing and continuous integration.

    2. Why is it ?Why your client start adopting it?

    • Current metadata is not isolated or organized in a way that makes it easy to upgrade and maintain.
    • SFDX force to create a well defined packages, Which are versionable and easy to maintain, update, install, and upgrade. With this updates and customization are much easier to manage across your development team
    •  Automated Data load between Orgs For Testing : We can avoid lot of  manual work with data loader and other tools usage
    • SFDX is future because its Salesforce official tool, So adopting to it is advisable
    • SFDX packages for everyone (Customer/SF partner/Consultant/Contractor),Not like earlier packages were traditionally only for  Salesforce Partners

    3. What is Artifacts?


    An artifact is a group of related code and customization's.

    4. What is SFDX Architecture?



    5. Why Salesforce is focusing on Source based development now ?
    1. The use of version control is at the heart of all modern development practices(.Net/Java). 
    2. It’s the basic prerequisite for automating deployments, testing, quality and security analysis.
    3. Most important work will not be lost.
    6. What is the Dev Hub, Scratch Org?What is Scratch Org ? What is it's lifespan?

    Dev Hub : Allows you to create and manage scratch orgs.

    Note : This can be enabled in any paid(Prod/Business) org & Also in Developer /Trail Org

    Scratch Org : This is a source driven and disposable deployment of Salesforce code and metadata,Made for developers and automation.

    Life Span: Scratch Org are ephemeral in nature,Max - 30 Days,Default - 7 Days

    7. Is there any additional cost to enable Dev Hub ?

    No

    8. How to setup SFDX ?
    1.Enable Dev Hub
    2.Create Scratch Org
    3. Install Salesforce CLI,Download
    4. Install Salesforce Extension for Visal Studio Code,Download
    5. Install Git Hub / Other source safe,Download

    9. What is Salesforce CLI ,Mention few key benefits & Installation guidelines?


    Salesforce CLI: This is a powerful command line interface that simplifies development and build automation when working with Salesforce Org.

    Key Benefits :
    1. Package development process from the command line.
    2. This is "Salesforce CLI" not the "Salesforce DX CLI" ,Which means this can be used against any org not only to Scratch Org.
    3. This combines many capabilities from across several  Salesforce API's
      • Metadata API
      • Tooling API
      • Data(SOAP) API
    4. It also supports the functionality of  ANT migration tool,Which allows scripting the metadata tasks. 
    5. Synchronize source to and from scratch orgs
    6. Create and Manage orgs
    7. Import and Exports data
    8. Create and Execute tests
    9. Create and Install packages 
    Installation Guidelines :
    1.After successful installation,An exe file should be available in below path
    Go To --> C:\Program FIles \ Saleforce CLI \ bin

      2.Add environment path variable
    Go To --> Windows Search --> Edit Environment Variables For Your Account


    10. What is Salesforce Extension for VS Code?
    This extension pack includes tools for developing on the Salesforce platform in the lightweight, extensible VS Code editor. These tools provide features for working with development orgs (scratch orgs, sandboxes, and DE orgs), Apex, Aura components, and Visualforce.

    11. Is there any limit on number of Scratch Org Creation ?
    Yes,To ensure optimal performance.
    Active Scratch Org Vs Daily Scratch Org
    1.Active Scratch Org : @ any point you can not have more than the number of active (Non-Expired & Non-Deleted) scratch orgs as given below based on license.
    2. Daily Scratch Org : These are the allowed number how many can be created each day.
    Ex: 200 for unlimited But can have active 100,So delete 100 and create new 100,Again u can delete upto 100 and allowed to create new 100 per day.After that if u delete 1 and try to create new 1 it will not allow since you have completed daily quota of 200 scratch org creation,Need to wait till next day.



    12. Scratch Org VS Sandboxes?


    Scratch Org compliments Sandboxes but do not replace them.


    Sandbox
    Scratch Org
    Immortal (Living forever) in nature
    Ephemeral (Lasting for very short time) in nature
    Production,Integration Testing,Full Copy staging will use sandbox
    Development,SIT phase best to use Scratch Org
    All developers of the project team work in same org,Difficult to track the changes done by individual.
    Each developer will have a dedicated scratch org which helps easy tracking of changes.
    Sandbox doesn’t support “Source Synchronization”.
    Ex:If developer miss to commit few changes from org to version control will lose the track & Later face difficulty while deployment and it’s very difficult to find under development for a long time.
    Scratch Orgs support "Source Synchronization", which means you can just run `sfdx force:source:pull` and `sfdx force:source:push` to synchronize metadata between version control and your org.

    13. Version control,CI CD can be done using Sandbox based development process also then why SFDX ?

    Yes,Many clients are already setup version control and CD using Sandbox based dev process.But in that scenario,version control necessarily lags behind the development org,
    And development sandboxes are the actual source of truth.That can be overcomes by using SFDX.The scratch org are ephemeral which forces developers to not relay on the org,But instead to persist their work in version control.

    14. SFDX Pros and Cons ?


    Pros :
    • SFDX force to create a well-defined packages, Which are versionable and easy to maintain, update, install, and upgrade. With this updates and customization's are much easier to manage across your development team
    •  Automated Data load between Orgs For Testing : We can avoid lot of  manual work with  data loader and other tools usage
    • SFDX packages for everyone (Customer/SF Partner/Consultant/Contractor),Not like earlier packages were traditionally only for  Salesforce Partners
    • It provides with an integrated, end-to-end lifecycle designed for high-performance agile development
    • It tracks any change you make locally in the project and any changes you have made in your scratch org
    • Reduced integration/testing time due to rapid setup of Scratch Orgs
    • Facilitates automated testing and continuous integration
    • Environments are easily created and disposable
    • Use any tool to modify code (CLI, Vim, Sublime, Atom etc)
    Cons :

    • Modularizing packages is very challenging for the existing big project
    • New tool & Few features might be missing but there is continuous improvements going on this
    • Takes bit of time to adopt,New development cycle & Technology as VCS as source of truth instead of sandbox 
    •  Significant learning & understanding is needed to start with
    • Salesforce CLI installs locally
    •  If your application involves building an extension package on top of existing managed package applications like Health Cloud, CPQ ,Financial cloud etc .Some of these apps require specific permission set licenses that are not available in scratch orgs yet .Also these apps involve too many customization that its almost easier to create sandbox environment from Trialforce templates for development than scripting all these via DX .(Safe Harbor — There are snapshots and templates features thats planned this might go away)

    15. What is mean by SFDX keep track of Local & Scratch Org changes automatically?Then why do we need push and pull ?
    It will keep track of changes and push or pull only those changes when command is performed ,
    It will not do auto sync but keep the track of changes.

    16. Why do we need to modularize the package ?
    If we have more projects in one production org definitely have more metadata components.
    And we will not able to say which metadata is part of which project.Maintenance is difficult.
    Ex: 10K metadata components and modifying of one component not sure
    where it will be impacted
    Note : If we maintain naming conventions that may help to some extent to find the grouping
    & Dependencies.


    17. SFDX Limitations & Workarounds?
           Refer


    18. List few Salesforce CLI commands ?
     

    Salesforce CLI Command
    Details
    List all available CLI commands
    Sfdx force:doc:commands:list
    To open scratch org,
    The default user is admin without password,If requires password.
    Note : Try this user login from other system CLI
    sfdx force:org:open -u test-rnfwyhrua8ed@example.com
    push (synchronize) your new code from local folder to the scratch org
    sfdx force:source:push

    synchronize changes in your local project to a scratch org with the alias MyScratchOrg

    sfdx force:source:push -u MyScratchOrg

    To open the scratch org
    sfdx force:org:open
    Pulls the latest from scratch org to local folder
    sfdx force:source:pull
    Create a project
    Ex:MyNew App
    Sfdx force:project:create -n MyNewApp
    Data transfer
    Ex:Existing accounts
    Sfdx force:data:tree:import -sobjecttreefiles data/Account.json
    Show the expiration date of scratch org
    sfdx force:org:display
    Create a new Apex
    Ex:NewClass
    Sfdx force:apex:class:create -n newClass -d force-app/main/default/classes
    Create new lightning component
    Sfdx force:lightning:component:create - Listview -f force-app/main/default/aura


    SFDX CLI command sfdx force:auth:web:login will not work if you’re trying to login to a sandbox org. This will open up a window to login.salesforce.com 
    Solution :
    sfdx force:auth:web:login -r https://test.salesforce.com

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

    19. Use of "sfdx-project.json"?
    Information required to track source and metadata with your scratch org
    A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.
    • sfdx-project.json
    • config/project-scratch-def.json
    • .forceignore

    20. What are the different types of packages available in Salesforce?


    Package Name
    Details
    Managed Package
    • Managed packages are typically used by Salesforce partners to distribute and sell applications to customers.
    • Using the AppExchange and the License Management Application (LMA), developers can sell and manage user-based licenses to the app.
    • Managed packages can be upgraded in the installer's organization. 
    • Some components are locked, ensuring a smoother upgrade process.
    Unmanaged Package
    • Unmanaged packages are typically used to distribute open-source projects or application templates to provide developers with the basic building blocks for an application.
    • Unmanaged Packages cannot be upgraded in the installer’s organization.
    • Unmanaged Packages do not include any locked components,Its open to edit code.
    2nd Generation Package

    Locked Package

    Unlocked Package



    21. Any additional cost for Salesforce DX ?


    No,There is no additional cost.

    22. What is Appirio DX ?


    AppirioDX commands like adx sfdx:init can help by automating the entire process of creating these orgs, installing packages, pushing metadata, sample data, and configuration data, and assigning permission sets.


    Reference:




    1 comment:



    1. Techforce services is a Salesforce Consulting Services in Australia Specialising in delivering end to end Salesforce solutions ,Consulting, Implementation DevOps partners in australia We deliver applications and services more rapidly and reliably, but it’s more than a methodology – it cuts to the very core.Salesforce Data Analytics let us help you become a data driven organisation and ensure your data is working hard for your business This includes implementi
      Salesforce Consulting Services in Australia
      Salesforce Staff Augmentation in Australia
      Salesforce Data Analytics
      DevOps Partners in Australia
      Managed Projects Salesforce Australia

      ReplyDelete