본문 바로가기

스타 블로그

SFDX – Salesforce Command Line Interface (CLI) Commands

반응형

In this blog, I would like to share with you the available Salesforce CLI Commands. CLI Commands will reduce your effort in creating and configuring the Apex, Visualforce, Lightning components. Refer to my previous blogs for setting up the SFDX with visual studio code IDE.

Prerequisites

Run Salesforce CLI Commands

To run the command from Visual Studio Code, open the command palette by pressing Ctrl + Shift + P or Cmd + Shift + P or from the Integrated terminal (Ctrl+Cmd+`).

SFDX Commands – on Command Palette

Integrated Terminal – with Login CLI Command

Available Salesforce CLI Commands

  1. Authorize Or Login To An Org Using The Web-Based Flow

force:auth:web:login clientid setdefaultdevhubusername setalias  —instanceurl <https://test.salesforce.com>

    • setdefaultdevhubusername – set the org to be default developer hub org.  optional parameter
    • setalias –  to set the alias name for the connected org by mapping the session id (only generated on successful login)
    • clientid  Consumer key of the connected app, optional parameter
    • instanceurl – Instance Url of the org to be connected,  https://login.salesforce.com be the default instance URL

Use the –setdefaultdevhubusername parameter only when authorizing a Dev Hub org. Do not use it when authorizing to other orgs, such as a sandbox.

More details

2.Logout From Connected Orgs

force:auth:logout –all | –targetusername  – -noprompt

  • – -all | -a  – Includes all authenticated orgs: for example, Dev Hubs, sandboxes, DE orgs, and expired, deleted, and unknown-status scratch orgs, Optional
  • – -noprompt |-p –  do not prompt for confirmation, Optional
  • – -targetusername | -u  – a username or alias for the target org. Overrides the default target org, Optional

– – all and – -targetusername can’t be used together.

More details.

3.Lists All Orgs That The Salesforce CLI Has Created Or Authenticated

sfdx force:org:list – -all

  • – -all –Lists all authenticated orgs, including expired, deleted, and unknown-status scratch orgs, Optional
  • – -clean –  Remove all local org authorizations for deleted or expired orgs, Optional
  • -p |- -noprompt – Do not prompt for confirmation, Optional

More details.

4.Lists All Alias

sfdx force:alias:list

Lists the aliases that the Salesforce CLI can use for various commands and tasks

5. Open A Connected Org Or Org Component

Opens an org in your browser.

sfdx force:org:open -u <Alias | username> -p <Path to components>

  • -p | –path- Navigation URL path (not including domain), Optional
  • -r | –urlonly  –  Displays a navigation URL but doesn’t launch your browseOptional
  • -u | –targetusername – username or alias for the target org. Overrides the default target org, Optional

Example

sfdx force:org:open -u sfdcEvangel

sfdx force:org:open –path one/one.app

More Details.

In the next blog, I will explain about the commands related to scratch org management.

 

Don’t forget to share the post if you like it & bookmark the blog for future references. If you have any comments or doubts on this post, Please comment on the box.

 

References

https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm

반응형