Tag: Salesforce DX

Salesforce DX Absolute Beginner ( Part 2 Of 7 )

This is the second part of the salesforce DX introduction series. In this second part of series, I am going show the complete set of the salesforce dx installation and the tool that need to required for development. I am going to use Visual Studio for the development.The Salesforce extensions for Visual Studio Code are a set of enhancements for custom development on the Salesforce Platform. If you want to try out Salesforce DX first, you can sign up for a trial org that has Dev Hub enabled.

Salesforce CLI Installation

The Salesforce CLI is a powerful command-line interface that simplifies development and builds automation when working with your Salesforce Org. You install the Salesforce CLI on Windows with a .exe file. You can Download and run the Windows installer from this link.

Visual Studio Code Installation

We are using the visual studio code.Go and download the  Visual Studio code installation from this link.

Salesforce Extensions for VS Code

This extensions bundle includes tools for developing on the Salesforce platform using the Salesforce DX development flow in the lightweight, extensible VS Code editor. These tools provide features for working with scratch orgs, Apex, Lightning components, and Visualforce.

To use Salesforce Extensions for VS Code, install all the extensions in this extension pack.

salesforcedx-vscode-core

This extension interacts with the Salesforce CLI to provide basic Salesforce DX functionality. After you install the visual studio code, launch the visual studio code to install the plugins. This extension enables VS Code to use the Salesforce CLI to interact with your scratch orgs. 

To run a command from Salesforce Extensions for VS Code, press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows or Linux) and type SFDX in the command palette.

Command palette, filtered to show SFDX commands

To see the output of the commands that you run, select View > Output, and then select Salesforce DX CLI from the drop-down menu. Alternatively, click Show in the completion notification.

salesforcedx-vscode-apex-debugger

This extension enables VS Code to use the real-time Apex Debugger with your scratch orgs.This extension enables VS Code to use the real-time Apex Debugger with your scratch orgs.

salesforcedx-vscode-lightning

This extension supports Lightning component bundles. It uses the HTML language server from VS Code.

salesforcedx-vscode-visualforce

This extension supports Visualforce pages and components. It uses the Visualforce Language Server and the HTML language server from VS Code.

Quick Recap of part 2 before going to part 3.

  • Install DX
  • Install the visual studio code and salesforce plugins
  • sign up for salesforce dx for development.

 

 

 

Salesforce DX for Absolute Beginners ( Part 1 Of 7 )

Introduction 

This is the first part of the salesforce DX introduction series. Salesforce DX is a combination of the set of tools like  Salesforce DX CLI and IDE’s like Force.com IDE 2 or Visual code Studio and set of new features that affect the app development lifecycle.Salesforce Developer Experience (DX) is a new way to manage and develop apps on the Lightning Platform across their entire life cycle. It brings together the best of the Lightning Platform to enable source-driven development, team collaboration with governance, and new levels of agility for custom app development on Salesforce.Below are the few highlights of salesforce DX

  1.  Powerful command-line interface (CLI) to manage development lifecycle
  2. Flexible and configurable scratch org which are easy to create and dispose
  3. You can use any IDE or text editor
  4. The ability to apply best practices to software development.
  5. You can use tools to build Continuous Integration and Continuous Delivery.
  6. You can build and test  the application  independently into small packages
  7. Packaging supports for agile distribution
  8. Enable Second-Generation Packaging (2GP) in your org so you can develop 2GP packages.

The below image shows the life cycle of applications development management with Salesforce DX.

Artifact-Based Development

Salesforce DX aims to remodel your development process by providing the major improvements required to manage a complex org with multiple development teams. To realize these improvements, Salesforce DX shifts the model of development from a monolithic org-based development process to a modular artifact-based development process. An artifact is a group of related code and customizations. An artifact can be tested independently from other components in your Org. An artifact should be able to be released independently as well. The metadata components within an artifact can only live in one artifact at a time. The modular artifact-based development gives you more flexibility in managing your teams and releases. You can assign teams to own a particular artifact. Development teams can develop separately and build toward a release of the artifact, and not a release of updates to the Org. With this agile model, you can have more frequent, independent releases, as you can see in the development, build, and deploy flow.

Dev Hub

 

                        Dev Hub is the First point to start using salesforce DX. Enable Dev Hub in your org so you can create and manage scratch org from the command line and Lightning Experience.   Dev Hub comprises objects with permissions that allow admins to control the level of access available to a user and an Org. You can enable dev from the salesforce development menu under setup.
Once you enabled you can start using the CLI to login into the Dev Hub

CLI 

Salesforce DX is come up with the powerful CLI to interact with application lifecycle. Use the Salesforce command-line interface (CLI) for most Salesforce DX tasks. These tasks include authorizing a Dev Hub org, creating a scratch org, synchronizing source code between your scratch org and VCS, and running tests and other.

You can use CLI in few of the cases

  • Login to the Dev Hub and Create a Scratch Org.
  • Sync Source from and to the Scratch org and Local code base
  • Import and export data setup
  • Test execution
  • Integrate version control and Continuous Integration and Continuous delivery models.

Scratch Org

                    Scratch org short time development org which can be used to develop or build any application on Salesforce.   The scratch org is a source-driven and disposable deployment of Salesforce code and metadata. A scratch org is fully configurable, allowing developers to emulate different Salesforce editions with different features and preferences. And you can share the scratch org configuration file with other team members, so you all have the same basic org in which to do your development.Scratch org drive developer productivity and collaboration during the development process and facilitate automated testing and continuous integration. You can use the CLI or IDE to open your scratch org in a browser without logging in. You might spin up a new scratch org when you want to:
  • Start a new project.
  • Start a new feature branch.
  • Test a new feature.
  • Start automated testing.
  • Perform development tasks directly in an Org.
  • Start from “scratch” with a fresh new org

You can spin the scratch org from the CLI by using the following command

The scratch org definition file(project-scratch-def.json) is a blueprint for a scratch org. It mimics the shape of an org that you use in the development lifecycle, such as the sandbox, packaging, or production.
  • Edition—The Salesforce edition of the scratch org, such as Developer, Enterprise, Group, or Professional.
  • Add-on features—Functionality that is not included by default in an edition, such as multi-currency.
  • Org preferences—Org and feature settings used to configure Salesforce products, such as Chatter and Communities.
 project-scratch-def.json

          Setting up different scratch org definition files allows you to easily create scratch org with different shapes for testing. For example, you can turn Chatter on or off in a scratch org by setting the ChatterEnabled org preference in the definition file. If you want a scratch org with sample data and metadata like you’re used to, we have an option for that: hasSampleData as shown below.

 Salesforce DX Project Structure 

              A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.Use the force:project:create command to create a skeleton project structure for your Salesforce DX project. If you don’t indicate an output directory, the project directory is created in the current location. You can also specify the default package directory to target when syncing source to and from the scratch org. If you don’t indicate a default package directory, this command creates a default package directory, force-app with the project folder name as DXLearning.

The force:project: create command generates these samples configuration files to get you started as shown below.

The project configuration file sfdx-project.json indicates that the directory is a Salesforce DX project. The configuration file contains project information and facilitates the authentication of scratch org and the creation of second-generation packages. It also tells Salesforce DX where to put files when syncing between the project and scratch org.
below is the sample sfdx-project.json file 
sfdx-project.json

Overall here are the highlights about the salesforce dx before going to part 2.

  • Dev Hub allows you to create and manage scratch org from the command line.
  • Scratch Org is a source-driven and disposable deployment of Salesforce code and metadata.
  • CLI to interact with Scratch Org, Dev Hub and application lifecycle.