Here are the new and changed features in recent updates of the sf executable of Salesforce CLI.
We publish a new stable version of sf on Wednesday. At the same time we also publish an sf release candidate that contains changes that we plan to include in next week's sf release.
Run sf version to display the version of sf installed on your computer.
Installation: If you installed Salesforce CLI with the sfdx installers, then sf is also installed automatically. If you installed sfdx via npm then you must install sf separately by running npm install @salesforce/cli -g.
Update: If you installed sf with the sfdx installers, run sfdx update to update to the latest available stable version. Run sfdx update stable-rc to update to the release candidate. To return to the stable version, run sfdx update stable.
If you installed sf with npm, run npm install @salesforce/cli@latest-rc -g to update to the release candidate. To return to the stable version, run npm install @salesforce/cli@latest -g.
Click here for the release notes for the sfdx executable.
Additional documentation:
- Salesforce CLI Command Reference (sf)
- Get Started with Salesforce CLI Unification
- Salesforce CLI Plugin Developer Guide (sf)
- Salesforce CLI Setup Guide
These changes are in the Salesforce CLI release candidate. We plan to include these changes in next week's official release. This list isn't final and is subject to change.
-
NEW: We now install some plugins just when you need them, rather than include them automatically in a Salesforce CLI release. Let's use the updated plugin-packaging as an example. The plugin isn't included in
sfby default, althoughsfknows about it. When you run one of the plugin's commands for the first time, such assf package version create, Salesforce CLI installs the latest released version of the plugin and then runs the command. The installation happens automatically, although we display a little message so you know what's going on. From then on, run any of the commands contained in the plugin as usual. When you update Salesforce CLI withsfdx update, the plugin is also updated to its latest release. Just a little just-in-time magic! -
NEW: We continue to improve the usability of existing
sfdxcommands so they work like thesfcommands. We're doing this work plugin by plugin. As a result of this work, when a Salesforce CLI release includes an updated plugin, you can execute the plugin's commands in bothsfdxANDsf. See this blog post for details.This week's release includes the updated plugin-apex and plugin-templates. Consequently, you can now run these existing
sfdxcommands insf:sf analytics generate template: Create a simple Analytics template.sf apex run: Execute anonymous Apex code entered on the command line or from a local file.sf apex generate class: Create an Apex class.sf apex generate trigger: Create an Apex trigger.sf apex get log: Fetch the specified log or given number of most recent logs from the org.sf apex list log: Display a list of IDs and general information about debug logs.sf apex tail log: Activate debug logging and display logs in the terminal.sf apex get test: Display test results for a specific asynchronous test run.sf apex run test: Invoke Apex tests in an org.sf lightning generate app: Create a Lightning App.sf lightning generate component: Create a bundle for an Aura component or a Lightning web component.sf lightning generate event: Create a Lightning Event.sf lightning generate interface: Create a Lightning Interface.sf lightning generate test: Create a Lightning test.sf static-resource generate: Create a static resource.sf visualforce generate component: Create a Visualforce Component.sf visualforce generate page: Create a Visualforce Page.
We also changed the official name of the existing
sf generate projectcommand tosf project generate.In addition to the two new included plugins, we also added plugin-packaging as a just-in-time plugin. We decided to make it a just-in-time plugin because not all of you use the packaging commands regularly. See the previous release note about how this type of plugin works. After Salesforce CLI installs the plugin, you can run these existing
sfdxcommands insf:sf package1 version create: Create a first-generation package version in the release org.sf package1 version create get: Retrieve the status of a package version creation request.sf package1 version display: Display details about a first-generation package version.sf package1 version list: List package versions for the specified first-generation package or for the org.sf package create: Create a package.sf package delete: Delete a package.sf package install: Install a version of a package in the target org.sf package install report: Retrieve the status of a package installation request.sf package installed list: List the org’s installed packages.sf package list: List all packages in the Dev Hub org.sf package uninstall: Uninstall a second-generation package from the target org.sf package uninstall report: Retrieve the status of a package uninstall request.sf package update: Update package details.sf package version create: Create a package version in the Dev Hub org.sf package version create list: List package version creation requests.sf package version create report: Retrieve details about a package version creation request.sf package version delete: Delete a package version.sf package version displayancestry: Display the ancestry tree for a 2GP managed package version.sf package version list: List all package versions in the Dev Hub org.sf package version promote: Promote a package version to released.sf package version report: Retrieve details about a package version in the Dev Hub org.sf package version update: Update a package version.
As always, run the commands with
--helpto see the list of flags, examples, and usage information. We'll be releasing other updated plugins over the next weeks. Enjoy! -
NEW: The
sf org displayoutput now includes the API version of the org at the time you authorized it with thesf login orgcommand. We cache the value locally, so if Salesforce updates your org to a new release, the API version will be incorrect. Re-login to your org to refresh the API version information in thesf org displayoutput. (GitHub issue #314, plugin-org PR #580) -
NEW: Configure autocomplete on Zsh for commands that use spaces as separators by running this command:
sf autocomplete
Follow the displayed instructions to set up autocomplete in your environment. Then use the tab key to autocomplete commands. For example, if you type
sf datathen press TAB, you'll get a list of data commands to chose from. You can also autocomplete flags:- Type
-to see suggestions that show both the long and short flag names. For example, if you typesf data query -then press TAB, zsh displays all the flags for this command, including both short and long names. If you typesf data query --, then only the long names are shown. - For flags that define a set of valid values, type
--<flagname>to see the list. For example, if you typesf data query --result-formatthen press TAB, zsh suggests the valid options for this flag, which arehuman,json, orcsv. - Flags that can be specified multiple times are still suggested, even if you've already used it.
If you currently use autocomplete for colon-separated commands, you must regenerate the autocomplete cache to get this new behavior; nothing in your environment changes otherwise:
sf autocomplete --refresh-cache
If you regenerate the cache, but then want to go back to autocompleting commands that use
:as a separator, first set this environment variable:OCLIF_AUTOCOMPLETE_TOPIC_SEPARATOR=colon
Then regenerate the autocomplete cache (
sf autocomplete --refresh-cache). - Type
-
CHANGE: Remember when we added
plugin-custom-metadata,plugin-signups, andplugin-communitytosf? We're changing them to just-in-time plugins, because, like packaging, not all of you use these commands regularly.
-
CHANGE: We upgraded the version of Node.js contained in the Salesforce CLI installers and TAR files to v18.14.0.
-
FIX: The
sf data querycommand no longer suppresess or nullifies the value of0(in human-readable output) when it's returned by a SOQL query. (GitHub issue #1892, plugin-data PR #470)Many thanks to Leo Stewart for reporting the issue, and then providing the fix. We're stoked with your contribution, and we look forward to more from you and community!
-
FIX: The
sf deploy|retrieve metadatacommands now support the ExperiencePropertyTypeBundle metadata type.
-
CHANGE: As part of this project, we changed the official name of these existing
sfcommands:Old command name New command name sf env create sandboxsf org create sandboxsf env create scratchsf org create scratchsf env delete sandboxsf org delete sandboxsf env delete scratchsf org delete scratchsf env resume sandboxsf org resume sandboxsf env resume scratchsf org resume scratchWe also brought over these org-specific
sfdxcommands:sf org display: Display information about an org.sf org list: List all orgs you’ve created or authenticated to.sf org open: Open your default scratch org, or another specified org, in a browser.
We recommend you use their
envequivalents (sf env display|list|open) for Salesforce Functions. -
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- AccountingFieldMapping
- AccountingModelConfig
- ActionLauncherItemDef
- ActionableListDefinition
- ExplainabilityMsgTemplate
- IntegrationProviderDef
- LocationUse
- PersonAccountOwnerPowerUser
- PipelineInspMetricConfig
- ProductSpecificationTypeDefinition
These changes are in the Salesforce CLI release candidate. We plan to include these changes in next week's official release. This list isn't final and is subject to change.
-
NEW: We continue to improve the usability of existing
sfdxcommands so they work like thesfcommands. We're doing this work plugin by plugin. As a result of this work, when a Salesforce CLI release includes an updated plugin, you can execute the plugin's commands in bothsfdxANDsf. See this blog post for details.This week's release includes the updated plugin-user. Consequently, you can now run these existing
sfdxcommands insf:sf org assign permset: Assign a permission set to one or more users of a scratch org.sf org assign permsetlicense: Assign a permission set license to one or more users of a scratch org.sf org create user: Create a user for a scratch org.sf org display user: Display information about a Salesforce user.sf org generate password: Generate a random password for scratch org users.sf org list users: List all locally-authenticated users of an org.
As always, run the commands with
--helpto see the list of flags, examples, and usage information. We'll be releasing other updated plugins over the next weeks. Enjoy! -
CHANGE: We changed the official names of these
sfcommands that we recently added:Old command name New command name sf generate cmdt objectsf cmdt generate objectsf generate cmdt fieldsf cmdt generate fieldsf generate cmdt fromorgsf cmdt generate fromorgsf generate cmdt recordsf cmdt generate recordsf generate cmdt recordssf cmdt generate recordssf generate metadata fieldsf schema generate fieldsf generate metadata platformeventsf schema generate platformeventsf generate metadata sobjectsf schema generate sobjectsf generate metadata tabsf schema generate tab -
FIX: When running
sf env delete scratch|sandboxto delete a scratch or sandbox org, all local source tracking files associated with the deleted org are cleaned up correctly. (GitHub issue #1879, sfdx-core PR #754) -
FIX: The
cmdt generate recordcommand is now working correctly and no longer returnsError: Unexpected arguments. (GitHub issue #1893, plugin-custom-metadata PR #380)
-
NEW: We continue to improve the usability of existing
sfdxcommands so they work like thesfcommands. We're doing this work plugin by plugin. As a result of this work, when a Salesforce CLI release includes an updated plugin, you can execute the plugin's commands in bothsfdxANDsf. See this blog post for details.This week's release includes updated plugin-signups. Consequently, you can now run these existing
sfdxcommands insf:sf org create shape: Create a scratch org configuration (shape) based on the specified source org.sf org delete shape: Delete all org shapes for a target org.sf org list shape: List all org shapes you’ve created.sf org create snapshot: Create a snapshot of a scratch org. (Pilot)sf org delete snapshot: Delete a scratch org snapshot. (Pilot)sf org get snapshot: Get details about a scratch org snapshot. (Pilot)sf org list snapshot: List scratch org snapshots. (Pilot)
As always, run the commands with
--helpto see the list of flags, examples, and usage information. We'll be releasing other updated plugins over the next weeks. Enjoy! -
NEW: You can now automatically replace snippets of your metadata source files with specific values right before you deploy the files to an org with the
sf deploy metadatacommand. This string replacement is "ephemeral" because the changes aren't written to your project; they apply only to the deployed files. Use this new feature to, for example, replace the endpoint in a NamedCredential, depending on whether you're deploying to a production or scratch org. Or specify a password in an ExternalDataSource that you don't want to store in your repo. The use cases are endless!To configure string replacement, add a
replacementsproperty to yoursfdx-project.jsonfile and use key-value pairs to describe how the string replacement works. See Replace Strings in Code Before Deploying for details and examples. This topic uses theforce:source:deploy|pushsfdx commands in the examples, but they apply equally tosf deploy metadata.Note these
sf-specific considerations:- By default, if you specify the
--jsonflag forsf metadata deploy, the JSON output includes areplacementsproperty that lists the affected files and the string that was replaced. Specify the--conciseflag to omit this information. - To view string replacement information in the
sf metadata deployhuman-readable output, specify--verbose.
- By default, if you specify the
-
NEW: We continue to improve the usability of existing
sfdxcommands so they work like thesfcommands. We're doing this work plugin by plugin. As a result of this work, when a Salesforce CLI release includes an updated plugin, you can execute the plugin's commands in bothsfdxANDsf. See this blog post for details.This week's release includes updated plugin-data, plugin-community, and plugin-custom-metadata. Consequently, you can now run these existing
sfdxcommands insf:sf community create: Create an Experience Cloud site using a template.sf community list template: Retrieve the list of templates available in your org.sf community publish: Publish an Experience Builder site to make it live.sf data create record: Create and insert a record into a Salesforce or Tooling API object.sf data delete bulk: Bulk delete records from an org using a CSV file.sf data delete record: Deletes a single record from a Salesforce or Tooling API object.sf data export tree: Export data from an org into one or more JSON files.sf data get record: Retrieve and display a single record of a Salesforce or Tooling API object.sf data import tree: Import data from one or more JSON files into an org.sf data query: Execute a SOQL query.sf data query resume: View the status of a bulk query.sf data resume: View the status of a bulk data load job or batch.sf data update record: Updates a single record of a Salesforce or Tooling API object.sf data upsert bulk: Bulk upsert records to an org from a CSV file.sf generate cmdt object: Generate a new custom metadata type in the current project.sf generate cmdt field: Generate a field for a custom metadata type based on the provided field type.sf generate cmdt fromorg: Generate a custom metadata type and all its records from a Salesforce object.sf generate cmdt record: Generate a new record for a given custom metadata type in the current project.sf generate cmdt records: Generate new custom metadata type records from a CSV file.
As always, run the commands with
--helpto see the list of flags, examples, and usage information. We'll be releasing other updated plugins over the next weeks. Enjoy!
ANNOUNCEMENT: Happy new year, Salesforce CLI community! Be sure to read our latest blog post that describes some of the big improvements that are coming in Salesforce CLI this year. And now back to our regular schedule.
-
NEW: As described in this blog post, we're updating many of the existing
sfdxcommands to use the improvements we made insf. We're doing this work plugin by plugin. When a Salesforce CLI release includes an updated plugin, you can execute the plugin's commands in bothsfdxANDsf. Let's see how this works.This week's release includes updated plugin-limits and plugin-schema. As a result, you can now run these existing
sfdxcommands insf:sf limits api display: Display information about limits in your org.sf limits recordcounts display: Display record counts for the specified standard or custom objects.sf sobject describe: Display the metadata for a standard or custom object or a Tooling API object.sf sobject list: List all Salesforce objects of a specified category.
As always, run the commands with
--helpto see the list of flags, examples, and usage information. We'll be releasing other updated plugins over the next weeks. Enjoy! -
CHANGE: Salesforce CLI has always automatically run a partial command if it finds only one option. For example, if you run
sf open, the CLI runssf env openautomatically because it's the only command that contains the fragmentopen. But now we warn you about it, just so you know exactly what command you just ran. [cli PR #475)
-
NEW: Get debugging information about any command execution with the new
--dev-debugflag. Each line in the debug output starts with the name of a function or plugin, such assf:core. Use these values to filter the debug output with the--debug-filterflag. For example:sf env list --dev-debug --debug-filter sf:core(salesforce/cli PR #452)
-
FIX: The
sf deploy|retrieve metadatacommands now support these metdata types used by Net Zero Cloud:- FuelType
- FuelTypeSustnUom
- SustainabilityUom
- SustnUomConversion
- FIX: We fixed some under-the-hood bugs.
- FIX: Any configured
postorgcreatehooks in custom plugins are now firing correctly after you runsf env create scratch|sandbox.
-
NEW: Do you write plugins for Salesforce CLI (
sfexecutable)? If so, check out the newsf dev audit messagescommand in plugin-dev. It audits your plugin's messages directory, looking for unused messages and missing messages referenced by your source code. If you don't specify any flags, you must run it from your plugin's top-level directory. First make sure you've installed the plugin:sf plugins install @salesforce/plugin-dev
Then change to your plugin directory and get an audit of your messages:
sf dev audit messages
Or run the command from anywhere and use the
--project-dirflag to specify your plugin directory:sf dev audit messages --project-dir /User/romeo/my-plugin (macOS/Linux) sf dev audit messages --project-dir c:\custom-plugins\my-plugin (Windows)
Maybe you haven't yet written your own
sfplugin, but you're curious? We've made it super easy. Check out the sf Plugin Developer Guide for all the deets, or just plunge right in. Happy coding! -
FIX: The
sf env resume scratchcommand displays the correct message. (GitHub issue #1701. sfdx-core PR #706)
- FIX: The
sf deploy|retrieve metadatacommands now support the ExtlClntAppMobileConfigurablePolicies metadata type.
-
NEW: Determine which plugin a command is in with the new
whichcommand. For example:$ sf which "deploy metadata" === deploy metadata plugin: @salesforce/plugin-deploy-retrieve -
FIX: The
sf deploy|retrieve metadatacommands now support these metdata types:- ExtlClntAppOauthConfigurablePolicies (previously called ExtlClntAppOauthPlcyCnfg)
- ExtlClntAppMobileSettings (previously called ExtlClntAppMobileSet)
-
NEW: Quickly gather Salesforce CLI configuration data and run diagnostic tests with the new
doctorcommand. Use the command to easily generate informational files that you can attach to GitHub issues or provide to Salesforce Customer Support.Run without parameters, the command first displays basic information, such as whether you're on the latest CLI version. It then writes your configuration and a detailed diagnosis to a JSON file in the current directory. Use the
--outputdirflag to specify a different directory. For example:sf doctor --outputdir diagnostic-filesUse the
--commandflag to run a specific command in debug mode; the doctor writes both stdout and stderr to separate*.logfiles. Encapsulate the command in double quotes. For example:sf doctor --command "env list --all"To run diagnostic tests on a specific plugin rather than the CLI itself, use the
--pluginflag. If the plugin isn't listening to the doctor, then you get a warning and no data.sf doctor --plugin @salesforce/plugin-deploy-retrieveWe've made it really easy to create a GitHub issue: specify the
--createissueflag, enter a title at the prompt, and a browser window automatically opens with a partially-filled GitHub issue. Enter the remaining information about your specific issue, click Submit new issue, and you're done. Easy peasy!The CLI doctor is in and ready to diagnose all your problems!
-
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- BotBlock
- ClauseCatgConfiguration
- DisclosureType
- DisclosureDefinition
- DisclosureDefinitionVersion
- ExtlClntAppOauthPlcyCnfg
- ExtlClntAppOauthSettings
- ExtlClntAppMobileSet
- OmniSupervisorConfig
-
NEW: Create aliases to simplify how you use the CLI with these new beta commands:
sf alias setsf alias unsetsf alias list
For example, scratch org usernames are long and unwieldy, such as
test-sadbiytjsupn@example.com. Creating an alias for the username, such asmy-scratch-orgmakes it easy to refer to it. Check the--helpof a CLI command to determine where you can use an alias.Here's how to set an alias to a scratch org username:
sf alias set my-scratch-org=test-sadbiytjsupn@example.comRefer to the alias this way:
sf deploy metadata --target-org my-scratch-org --metadata ApexClassEnjoy!
-
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- CallCtrAgentFavTrfrDest
- ExternalCredential
- MarketSegmentDefinition
- MfgProgramTemplate
- StreamingAppDataConnector
-
FIX: The
sf deploy metadatacommand correctly deploys any CustomFieldTranslation metadata types that have local changes. (PRs: source-deploy-retrieve #726 and #728, plugin-source #597, source-tracking #243) -
FIX: The
sf deploy metadatacommand correctly handles the new enhanced domains in Winter '23 preview sandboxes. [GitHub issue #1687. PRs: jsforce #1272, sfdx-core #667) -
FIX: The
sf deploy|retrieve metadatacommands now support the RelationshipGraphDefinition metadata type. [PR: source-deploy-retrieve #722)
- FIX: When you install a plugin with the
sf plugin installcommand,sfnow verifies its signature. If the plugin is unsigned,sfprompts you to confirm that you really want to install it. This behavior mimics the existing behavior ofsfdx.
- FIX: We fixed some under-the-hood bugs.
-
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- DigitalExperienceBundle
- DigitalExperience
- DigitalExperienceConfig
-
FIX: You can now correctly deploy empty metadata files; previously you'd get an UNKNOWN_EXCEPTION error. (GitHub issue #1673, SDR PR #705)
-
NEW: Retrieve components in metadata format with the new
--target-metadata-dir | -tflag of thesf retrieve metadatacommand. Metadata format refers to the file format used by the Metadata API. Previously, thesf retrieve metadatacommand retrieved files only in source format.With the new
--target-metadata-dirflag, the components in metadata format are retrieved into a ZIP file calledunpackaged.zip(by default) in the specified local directory. You must use this flag in combination with one of these flags so the command knows which components to retrieve:--source-dir,--manifest,--metadata, or--package-name.For example, this command retrieves all Apex classes from an org with alias
myorginto a ZIP file calledunpackaged.zipand puts it in the local directory calledmd-output:sf retrieve metadata --metadata ApexClass --target-metadata-dir md-output --target-org myorgCustomize the command output with these other new flags:
--single-package: Indicates that the retrieved ZIP file has a single package directory.--unzip, -z: Automatically extract the files from the downloaded ZIP file.--zip-file-name: Name for the downloaded ZIP file. Default isunpackaged.zip.
For example:
sf retrieve metadata --metadata ApexClass --target-metadata-dir md-output --unzip --target-org myorg -
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- ExternalClientApplication
- ForecastingFilter
- ForecastingFilterCondition
- SchedulingObjective
- FIX: The
sf deploy|retrieve metadatacommands now support the MarketingAppExtension metadata type.
-
NEW: Preview a metadata deployment or retrieval with the new
sf deploy|retrieve metadata previewbeta commands. They're likesfdx force:source:status, but smarter.The commands display a table of the metadata components that will be deployed or retrieved or deleted. The table also lists the conflicts between the source in your local project and the components in the org. Finally, the table lists components that won't be deployed or retrieved because they're included in your
.forceignorefile. Use the--ignore-conflictsto see what is deployed or retrieved when any conflicts are ignored. For example:sf retrieve metadata preview --ignore-conflictsThe
sf deploy metadata previewcommand also supports the flags to narrow what's deployed, such as--metadata,--manifest, or--source-dir. For example:sf deploy metadata preview --metadata ApexClass sf deploy metadata preview --source-dir force-app
-
NEW: Interactively create local Salesforce metadata, such as custom objects and platform events, with these new beta commands in the new plugin-sobject plug-in:
sf generate metadata sobject sf generate metadata platformevent sf generate metadata field
Each command requires the
--labelflag, and then uses the value to provide intelligent suggestions for its prompts, such as its API name. This example shows how to interactively create a custom object:sf generate metadata sobject --label "My Fab Object"Want to automatically enable optional features on the new custom object rather than answer all the prompts? Try this:
sf generate metadata sobject --label "My Fab Object" --use-default-featuresNow create a custom field on your shiny new object; the command prompts you for the object:
sf generate metadata field --label "My Field"Remember to run
sf deploy metadatato deploy the new local source files to your org. Then you can further customize the new components using Setup UI, thensf retrieve metadatathe changes back to your local project. How fun is that? -
NEW: Create a custom tab for a custom object with the new
sf generate metadata tabbeta command. You must provide the object's API name, icon number, and local directory to store the files. For example:sf generate metadata tab --object MyFabObject__c --icon 54 --directory force-app/main/default/tabs
- FIX: We fixed some under-the-hood bugs.
-
NEW: Search the
sfcommands for that special one you've been looking for all your life with the new interactivesf searchcommand. -
CHANGE: The
sf deploy|retrieve metadatacommands no longer support these metadata types associated with Connect Center:- ConnectedSystem
- DataMapping
- DataMappingObjectDefinition
- DataMappingSchema
- DataMappingFieldDefinition
- FederationDataMappingUsage
- FIX: We fixed some under-the-hood bugs.
-
FIX: Following our standard conventions, these commands no longer have the
-jshort flag for producing JSON output, only the--jsonlong flag:sf deploy functionssf env create computesf env deletesf env logdrain addsf env logdrain removesf env var setsf env var unsetsf logout functionssf run function
-
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- IdentityVerificationProcDef
- ServiceAISetupDefinition
- ServiceAISetupField
-
NEW: Get JSON output from these Salesforce Functions commands with the
--jsonflag:sf deploy functionssf env create computesf env deletesf env logdrain addsf env logdrain removesf env var setsf env var unsetsf logout functionssf run function
-
NEW: Stream log output for a compute environment with the new beta
sf env logcommand. For example:sf env log --target-compute environment-alias -
FIX: Refreshing expired access tokens is working as expected. (GitHub issue #1615, sfdx-core PR #619)
-
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- AIUsecaseDefinition
- DataPackageKitDefinition
- DataPackageKitObject
- DataSourceBundleDefinition
- DataSrcDataModelFieldMap
- DataStreamTemplate
- FIX: The
sf env create scratchcommand correctly labels a scratch org in its internal authentication files. (GitHub issue forcedotcom/cli#1598)
-
NEW: These commands now support source tracking:
sf deploy metadatasf deploy metadata validatesf retrieve metadata
The first time you run
sf deploy metadataon a scratch or sandbox org that allows source tracking, the command deploys all local source files. But when you next run the command, it deploys only the files that changed locally. Narrow the list of deployed files with the--source-dir,--metadata, or--manifestflags. If you don’t specify these flags, then the command deploys all changes in the project, similar to howforce:source:pushinsfdxworks.The
sf retrieve metadata command is the same as deploy, but in reverse. The first time you retrieve, everything is retrieved; the next time only changes in the org are retrieved. If you don’t specify--source-dir,--metadata, or--manifest, then all changes in the org are retrieved, just likeforce:source:pullinsfdx.If a command detects a conflict in the files you’re about to deploy or retrieve, the command displays the conflicts. Use the
--ignore-conflictsflag to force the deployment or retrieval of the changes. This flag is similar to the--forceoverwriteparameter of many of theforce:sourcecommands insfdx. For example:sf deploy metadata --source-dir force-app --ignore-conflictsSee Getting Started with Salesforce CLI Unification, which will soon be updated with additional details about source tracking in
sfand how it’s slightly different fromsfdx. -
NEW: Opt out of source tracking when you create a scratch or sandbox org with the new
--no-track-sourceflag of thesf env create scratch|sandboxcommands. Source tracking is enabled by default for orgs that support it. But you sometimes want to disable source tracking, such as in a CI/CD environment to improve performance. This example creates a scratch org with source tracking disabled:sf env create scratch --target-dev-hub=MyHub --definition-file config/project-scratch-def.json --no-track-source -
NEW: Get detailed information about the Salesforce CLI version you're using with the new
--verboseflag of thesf versioncommand. Output includes versions of the core and installed plug-ins, operating system information, and version of Node.js. -
FIX: Authentication tokens are now consistently and correctly encrypted or decrypted. (GitHub issue #1314)
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
-
NEW: Deploy components in metadata format with these new flags for the
sf deploy metadataandsf deploy metadata validatecommands:--metadata-dir: Either the root directory or the .zip file that contains the metadata formatted files you want to deploy.--single-package: Indicates that--metadata-dirpoints to a directory structure for a single package. By default, the deploy command assumes the directory is structured for a set of packages.
Metadata format refers to the file format used by the Metadata API. Previously, the
sf deploy metadataandsf deploy metadata validatecommands deployed files only in source format.If you use
--metdata-dirto deploy metadata formatted source files, you can't use the--metadata,--source-dir, or--manifestflags, which apply only to source formatted files.This example deploys the metadata formatted files in the
MyMdComponents.zipfile and specifies that the files are in a single package directory:sf deploy metadata --metadata-dir zips/MyMdComponents.zip --single-directory -
FIX: The
sf deploy|retrieve metadatacommands now support these metadata types:- AssessmentQuestion
- AssessmentQuestionSet
-
NEW: Check out these new beta commands that make deploying metadata easier than ever:
deploy metadata validate: Validate a metadata deployment without actually executing it.deploy metadata quick: Quick deploy a validated deployment to an org.deploy metadata resume: Resume watching a deploy operation.deploy metadata cancel: Cancel a deploy operation.deploy metadata report: Check the status of a deploy operation.
The
validateandquickcommands work together. They're useful if the deployment to your production org takes several hours and you don’t want to risk a failed deploy. You first validate a deployment to verify whether it will succeed, without actually deploying the metadata to your org. The command returns a job ID, which you then pass to thequickcommand to actually deploy the metadata. The quick deploy takes less time because it skips running Apex tests, which ran as part of the validation. Let's look at some examples.Validate the deployment to the org with alias
my-prod-orgof all source files in theforce-appdirectory:sf deploy metadata validate --source-dir force-app --target-org my-prod-orgWhen the command completes, you can pass the displayed job ID to the
quickcommand:sf deploy metadata quick --job-id 0Af0x000017yLUFCA2Use the
--asyncflag on either command to run it asynchronously; the command still displays the job ID but immediately returns the control of the terminal to you.sf deploy metadata validate --source-dir force-app --target-org my-prod-org --asyncResume watching the asynchronous command by passing the job ID to the
resumecommand:sf deploy metadata resume --job-id 0Af0x000017yLUFCA2Cancel a deploy operation that hasn't yet completed in the org using the
cancelcommand. In this context, "deploy operations" include standard deploys, quick deploys, deploy validations, and deploy cancellations.sf deploy metadata cancel --job-id 0Af0x000017yLUFCA2Want to check the status of a deploy operation? Use the
reportcommand:sf deploy metadata report --job-id 0Af0x000017yLUFCA2Lost the job ID? Don't panic! Specify the
--use-most-recentflag with any command that takes a job ID:sf deploy metadata resume --use-most-recentSee the
--helpof each command for more interesting flags and examples.
-
NEW: Manage scratch orgs and sandboxes with these new beta commands:
env create scratchenv resume scratchenv delete scratchenv create sandboxenv resume sandboxenv delete sandbox
Use the
createcommands to create scratch orgs and sandboxes. While executing, they display running information about the background processes, such as sending requests, deploying org settings, and so on. Pretty cool knowing what's going on behind the scenes, no? Use theresumecommand if the originalcreatecommand times out, or you specified the–async flagto run it asynchronously. Use thedeletecommands to, yep, you guessed it, delete a scratch org or sandbox! Let's run through a few scratch org examples to see the new commands in action.Create a scratch org from a definition file, set it as your default environment, give it an alias, and use the Dev Hub with alias
DevHub:sf env create scratch --definition-file config/project-scratch-def.json --set-default --alias myscratch --target-dev-hub DevHubCreate a Developer Edition scratch org using your default Dev Hub and give it an alias:
sf env create scratch --edition=developer --alias anotherscratchCreate a scratch org asynchronously. The command returns control to you right away and displays a job ID:
sf env create scratch --edition=developer --alias happyscratch --asyncResume the scratch org creation by passing the job ID to the
resumecommand:sf env resume scratch --job-id 2SR3u0000008fBDGXDDelete the scratch org when you’re done with it:
sf env delete scratch --target-org happyscratchThe sandbox commands work much the same, except they have a few additional flags specific to sandboxes, such as
–license-typeand–name. See the–-helpfor all the flags.
- CHANGE: We no longer support v12 of Node.js because of its fast approaching end-of-life (April 30, 2022). We bundle Node.js in each operating system-specific Salesforce CLI installer. We include the Active LTS version of Node.js and update it in tandem with the Node.js release schedule. If you prefer to install Salesforce CLI using
npm, we recommend you also use the Active LTS version of Node.js.
Starting today, sf commands that we're actively working on, but are publicly available, are marked with a beta tag. We can update these beta commands in any future release. While we try not make any breaking changes in these beta commands, we reserve the right to do so without warning. This process allows us to iteratively build sf and get feedback from you as we go.
As soon as we've finished working on a beta command, and we've provided ample time for improvements based on your feedback, we'll remove the beta tag. At that point, the command is GA and follows our deprecation policy.
A few additional notes:
- All beta
sfcommands have a correspondingsfdxcommand. - We don't recommend that you use the beta commands in your CI/CD scripts.
- We do recommend that you use and test the beta commands in your day to day CLI work and give us feedback early and often by entering GitHub issues.
sfcommands that support GA products and have nosfdxequivalents, such as Salesforce Functions, will never be marked as beta. These commands are GA from the moment the product itself goes GA and are subject to our deprecation policy.- New
sfcommands are marked with a beta tag by default, unless there are nosfdxequivalents and they support a GA product.
-
CHANGE: These commands are now marked beta; they behave the same as before:
sf deploy metadatasf retrieve metadata
- FIX: We fixed some under-the-hood bugs.
-
CHANGE: As part of the fix for GitHub issue #1408, Salesforce CLI now uses rotating log files. By default, every day at midnight the CLI makes a backup copy of the log file and then clears out its entries to start afresh. This new behavior ensures that the log file doesn't get too big. We keep backups for the past two days along with the current day’s logs.
Change the default behavior with these new environment variables:
- SF_LOG_ROTATION_PERIOD: How often a new log file is created. For example, a value of
1dmeans a new log file is created daily, at midnight. A value of2wcreates a new file every 2 weeks. See the period entry in this table for other options. Default value is1d. - SF_LOG_ROTATION_COUNT: Number of backup files to keep. Default value is
2.
For example, if you choose a rotation period of 2 weeks and a count of 2, you always have backups for the four weeks before the first entry in the current log.
- SF_LOG_ROTATION_PERIOD: How often a new log file is created. For example, a value of
-
CHANGE: We've changed the names of these configuration variables to better fit into the unified CLI world:
Old Name New Name apiVersion org-api-version disableTelemetry disable-telemetry instanceUrl org-instance-url maxQueryLimit org-max-query-limit restDeploy org-metadata-rest-deploy The new names interoperate with the equivalent
sfdxconfig values, just like the old names did. But you can no longer use the old names. For example:- If you run
sfdx config:set apiVersion=54.0, thenorg-api-versionis also set to54.0insf. - If you run
sf config set org-api-version=54.0, thenapiVersionis also set to54.0insfdx. - If you run
sf config set apiVersion=54.0, you get an error. Runsf config set org-api-verison=54.0instead.
We're in the process of updating the documentation.
- If you run
-
NEW: We've added the following new flags to the
deploy metadatacommand that mirror similar functionality in thesfdx force:source:deploycommand:--api-version: API version to use when deployng.--dry-run: Validate the deploy and run Apex tests but don't save to the org.--ignore-errors: Ignore any errors and don't roll back deployment.--ignore-warnings: Ignore warnings and allow a deployment to complete successfully.--tests: Apex tests to run when--test-levelisRunSpecifiedTests.--verbose: Show verbose output of the deploy result.
-
NEW: Get JSON output when running the
env var getcommand with the--jsonflag.
-
NEW: Salesforce CLI can now read your mind. Okay, not really, but the
sfexecutable got a lot smarter in this release. You can now enter command fragments in any order, and the CLI figures out what you mean. For example, let's say you want to log into an org using JWT but you forgot the exact command. All of the following commands work without returning anycommand not founderrors:sf login org jwt sf org login jwt sf jwt org login
But wait, there’s more. If you remember only part of a command, run the partial command anyway to see a handy list of all the commands that contain that part. Use arrows to highlight the one you want, then press return to choose it. For example, let's say you want to list all your environments, but can't remember the exact command name. Try this:
sf list ? Which of these commands do you mean (Use arrow keys) > config list > env list > env logdrain list > env var list
The command to list your environments is, wait for it...
sf env list!To narrow down a long list of possible commands, provide a flag. For example, if you run
sf list –all, it displays only theenv listcommand because it's the only one that has the–allflag.Each command still has a canonical signature, which we use in the
–helpexamples and to organize the Salesforce CLI Command Reference.Here's a fun activity: discover all the cool
sfcommands by simply entering keywords at the command line! -
NEW: We've improved how the interactive
sf deploycommand handles expired scratch orgs. As before, the command refers to thetarget-orgconfiguration variable when prompting you for the org to which to deploy. If, however, the scratch org it points to has expired, the command now asks if you want to deploy to a different org. If you do, the command gives you a list of orgs to choose from, and then asks if you want to set it as your default. Nice.
-
NEW: Add a Heroku user as a collaborator on a compute environment with the new
env compute collaborator addcommand. Specify the Heroku user's email address with the--heroku-userflag. After running the command, you can attach Heroku add-ons to the compute environment. For example:sf env compute collaborator add --heroku-user me@example.com
-
FIX: We've improved the error messages returned when you use one of these Salesforce Functions commands to run a JavaScript or TypeScript function that encounters unexpected data:
run function startrun function start localrun function start container
The improved error messages provide more information about the problem to help you understand what went wrong and how to proceed.
- CHANGE: When you run
sf update, we now warn you that it has no effect if you installedsfusing thesfdxinstaller. In this case, to updatesf, runsfdx update.
- FIX: We fixed some under-the-hood bugs.
-
NEW: Easily update
sfto any available version with the new--versionflag of theupdatecommand. Not sure which versions are available? Use the new--availableflag to list them. The output also handily includes the location of the version, either local (because you've previously installed it) or out there in the cloudy world. There's no need to download remote versions, thesf update --versioncommand does it for you. We've even added an--interactiveflag; use your cursor to choose the version from a list. For example:sf update --version 1.12.0 sf update --interactive sf update --available
Updating to the current or release candidate versions using the
stableorstable-rctags works as before:sf update stable-rc
NOTE: These update changes apply only if you installed
sfwith its installer. They don't apply if you installedsfwith either thesfdxinstaller ornpm.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
- CHANGE: Docker is no longer required when you develop a Salesforce Function locally using the
run function startcommand. Instead, you can build and run Functions on the host operating system, which results in a faster development cycle. If you want to continue using Docker for local Salesforce Functions development, use the newrun function local containercommand. This command behaves the same asrun function startdid before this release.
-
NEW: Build and run a Salesforce Function in a container with the new
run function start containercommand. -
FIX: We've switched the HTTP library used by the Salesforce Functions commands to ensure compatibility with customer VPNs.
- CHANGE: If the
info releasenotes displaycommand (aliaswhatsnew) can't find an exact match of the installed CLI version in the release notes, the command displays the notes for the closest version. The command behaves the same way if it can't find the exact version specified by the–versionparameter in the release notes.
NOTE: Because of the holidays, we're not publishing a new stable-rc release today or next week (Dec 30, 2021). We'll return to our regular weekly release schedule on Jan 6, 2022. (Wow, next year we'll be exactly 200 years away from the first every-digit-is-the-same year since 1111. Exciting stuff!) Happy holidays to our fabulous developer community, and see you next year!
-
NEW: Easily find the
sfcommand or flag you want to execute with the new autocomplete feature. It works the same as standard autocomplete on a terminal: it's all about the TAB key. First typesfat the prompt and then press TAB twice to view the full list of topics and top-level commands. Then type the first letter of a topic or command, press TAB again, and the CLI autocompletes it as best it can. Autocomplete works similarly with flags: after you've typed out a command, type a dash (-) then TAB twice to see the full list of available flags. Then type a letter and TAB to autocomplete a specific flag. Play around with it and you'll get the hang of it, don't worry!To install autocomplete, run
sf autocompleteand follow the instructions for your particular environment. For example, on macOS with the bash shell, you run this command, which updates your.bashrcfile:printf "eval $(sf autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrcAutocomplete on
sfis currently supported only on the macOS and Linux operating systems and the Bash shell. -
NEW: Quickly catch up on the new and changed features in any Salesforce CLI release with the new
info releasenotes displaycommand (aliaswhatsnew). By default, the command displays the release notes for the Salesforce CLI version that's currently installed. Use the--version|-vflag to specify a specific CLI version or a tag, such asstable-rc. For example:sf whatsnew sf whatsnew --version stable-rc sf whatsnew -v 1.6.0
-
CHANGE: Installing the
sfdxexecutable with thenpm install sfdx-cli -gcommand no longer installs the@salesforce/clipackage, which corresponds to thesfexecutable.To install
sfvia npm, run this command:npm install @salesforce/cli -g.Installing Salesforce CLI with the installers and TAR files hasn't changed; they still install both the
sfdxandsfexecutables.
- NEW: Build and run a Salesforce Function locally with the new
sf run function start localcommand.
- FIX: We fixed some under-the-hood bugs.
- FIX: We improved the automatic installation of
sfwhen you installsfdxusing the operating system-specific installers and TAR files.
- FIX: We fixed a bug that prevented
sfdx updatefrom also updatingsfto its latest version.
- FIX: We fixed some under-the-hood bugs.
- FIX: We fixed some under-the-hood bugs.
Welcome to the first GA release of the new sf executable of Salesforce CLI!
Salesforce CLI is a bundle of two executables: sf and sfdx. We first launched sfdx for you to develop and test your apps more easily on Salesforce Platform. But if you want to work across all Salesforce clouds, sfdx doesn’t provide all the commands you need. With sf, we're bringing together a cross-cloud set of commands that streamline how you build and deploy across Salesforce. See Get Started with CLI Unification for more information about the sf executable, such as how it works with sfdx, a mapping of the available sf commands to their equivalent sfdx commands, and more.
If you've already installed Salesforce CLI and are using sfdx commands, update the CLI to the latest version to also get sf:
sfdx update
NOTE: If you haven't already, uninstall the old salesforcedx plug-in to ensure the update succeeds.
Verify that you can use sf by running the help command, which lists the version and top-level topics:
sf help
You can also install sf with npm:
npm install @salesforce/cli --global
See Install sf for other installation options and troubleshooting information.
We've enhanced the command-line help to include additional information. As a result, the help can get long, so we've also changed the behavior of the flags:
-h: Displays a subset of the full help: short command and flag descriptions and command usage. Great for quick reference.--help: Displays the-hcontent plus longer command and flag descriptions, examples, and the configuration and environment variables that affect the command.
As far as the online documentation:
- The Salesforce CLI Command Reference contains reference information about both
sfandsfdxcommands. - For now, the Salesforce DX Developer Guide continues to use only the
sfdxexecutable in its examples. - The Salesforce CLI Setup Guide contains all the online information about
sfin a new Get Started section.
We want to hear from you! Enter any issues you encounter with the sf executable and feature requests in Issues tab of this GitHub repo.