61 votes
Accepted

Removing old hub org, or non-scratch org from Salesforce DX org list

It would be nice for this to be something in the actual CLI commands: the ability to clean up old orgs that are no longer needed. For the time being, you need to manually cleanup the DX configs in ...
user avatar
  • 19.1k
56 votes

Removing old hub org, or non-scratch org from Salesforce DX org list

It looks like rather than deleting a hub org, you just call: sfdx force:auth:logout -u <hub alias> You'll get a warning about being sure you want to log out. Once you do, that hub org will no ...
user avatar
  • 671
53 votes
Accepted

SFDX Pull fails because of AppMenu/AppSwitcher

Here is a workaround for this SFDC Platform Winter19 bug Create/update .forceignore file at the root of your SFDX Project, with the following content : # List files or directories below to ignore ...
user avatar
45 votes
Accepted

Salesforce DX - how to set default devhub if I missed the -d option when connecting to devhub

You can use sfdx force:config:set defaultdevhubusername=me@myhub.org. You can use the additional -g parameter if you want to set it globally. The related doc is here, in addition to using sfdx force:...
user avatar
35 votes
Accepted

How do I get Apex code coverage statistics when using Salesforce DX & Visual Studio Code

The easiest way to be able to view test coverage is to have set the --codecoverage flag (-c for short) to retrieve code coverage when you run the test command. > sfdx force:apex:test:run -c -u ...
user avatar
  • 19.1k
34 votes
Accepted

SFDX: Grant type not supported

The problem was that I was using the domain name instead of the plain test.salesforce.com. This doesn't work: sfdx force:auth:web:login -r https://xyz.lightning.force.com/ -a XYZ but this works: ...
user avatar
  • 5,248
26 votes
Accepted

How to run Apex anonymous code from Visual Studio Code

In the command palette, if you type "sfdx ex" you will be offered this if you have some Apex text selected: SFDX: Execute Anonymous Apex with Currently Selected Text or this: SFDX: Execute ...
user avatar
  • 130k
25 votes

Unlocked packages vs Unmanaged packages

Unlocked Packages are more like an advanced form of Managed Packages, not Unmanaged Packages. Many of the same differences exist for Unlocked Packages and Managed Packages as compared to Unmanaged ...
user avatar
  • 433k
22 votes
Accepted

SFDX 6.21.0-9db990b3c9 AND CURRENT Update - Error - sfdx no longer works

This happens to me every couple of days on a Mac. A workaround is to delete the directory /Users/xxxx/.local/share/sfdx/client and then sfdx-cli will automatically upgrade on the next command your ...
user avatar
  • 130k
21 votes

sfdx is not recognized as an internal or external command

1.Verify the "Salesforce CLI" installed successfully or not Go to → C:\Program Files\Salesforce CLI\bin → Verify sfdx.exe should be availble 2.Add this path to environment variables "Path" Go To → ...
user avatar
21 votes

Removing old hub org, or non-scratch org from Salesforce DX org list

D:\...>sfdx force:org:list === Orgs ALIAS USERNAME ORG ID CONNECTED STATUS ─── ──────────── ────────────────────────────────────────── ...
user avatar
20 votes
Accepted

Metadata Deploy and Push fails on Flexipage componentInstances in API 49 (Summer 20) and later

In the Summer 20 release, the componentInstances property for FlexiPage regions has been removed. These need to be replaced with itemInstances as outlined in the release notes. More details on the ...
user avatar
  • 19.1k
18 votes
Accepted

sfdx Deploy to existing salesforce instance?

Well, the sfdx command that you included in your comment is the correct one to use. If you're worried about messing up your production environment, why not use sfdx to deploy to a sandbox first? Any ...
user avatar
  • 48.1k
18 votes
Accepted

Run specific apex tests during "sfdx force:source:deploy"

Now with the latest sfdx update(7.21.0) you can run 'sfdx force:source:deploy' command with specific test classes. Check below command. sfdx force:source:deploy -p "./PathToMetadata" -l ...
user avatar
17 votes
Accepted

SalesforceDX CLI "sObject type 'SourceMember' is not supported" with source pull

You are correct that you can only do a source pull from a Scratch Org. You can retrieve the source from a managed or unmanaged package. Just put everything you want to retrieve into an unmanaged ...
user avatar
  • 1,387
17 votes

SFDX: Grant type not supported

@smukov is correct, don't use the lightning.force.com url. Instead find that url here for your sandbox and log in using the instance that shows in the url during Log In or in the sandbox "location" ...
user avatar
17 votes

How to push code to production with Visual Studio Code & DX

As of Summer '19 (v46.0), the INVALID_OPERATION errors you were hitting are no longer an issue! force:source:deploy now works when deploying to production. See an example below: sfdx force:source:...
user avatar
  • 4,702
16 votes

How to use "sfdx force:source:pull" with folders other than "main/default" where components are added in the scratch org?

Unfortunately, the CLI will always pull "Remote Add" metadata (ie. metadata not previously seen in any local SFDX Package Directory) into main/default/<metadata-type> inside of the ...
user avatar
16 votes
Accepted

Authorize Org failed in VS Code

The following solution worked for me Run command prompt 𝐚𝐬 𝐚𝐝𝐦𝐢𝐧 (𝘚𝘵𝘢𝘳𝘵 > 𝘤𝘮𝘥 > 𝘙𝘪𝘨𝘩𝘵-𝘊𝘭𝘪𝘤𝘬 > 𝘙𝘶𝘯𝘈𝘴 𝘈𝘥𝘮𝘪𝘯) Run the command: 𝐧𝐞𝐭𝐬𝐭𝐚𝐭 -𝐚𝐨𝐧 CTRL+F, to search ...
user avatar
15 votes
Accepted

Export SOQL CLI Results to CSV

There is --resultformat on query. sfdx force:data:soql:query -q "SELECT Id,Name,Status__c FROM Property__c" --resultformat csv` I got that from the command help. See below. -> sfdx force:data:...
user avatar
  • 593
15 votes

Can I use SalesforceDX to load data into sandboxes?

The short answer is: yes. All of the commands in the force:data command namespace work on any edition of Salesforce any org (provided API is enabled on that org). The long answer is: it depends on ...
user avatar
  • 19.1k
15 votes
Accepted

SFDX cli force:source vs force:mdapi?

What is the difference between force:source vs force:mdapi? The file and directory structures are different. force:source refers to the new "source" format, while force:mdapi refers to the old "...
user avatar
  • 433k
15 votes
Accepted

Unlocked packages vs Unmanaged packages

As for me, the most important difference is that the unlocked package uses SFDX for development. So you, as a developer, could create a package, create a new version, promote, install to org within ...
user avatar
15 votes
Accepted

Status 500, Internal server error when calling Apex from LWC

You are suppose to call the method like myCoolFunction({myParam:'param'}).then(result=>{ console.log(JSON.stringify(result)); }).catch(error=>{ console.log(...
user avatar
  • 2,814
14 votes

How to install managed package using Salesforce DX CLI?

To install a First Generation Managed Package via sfdx, you do it the same way you do it with the metadata API. The command looks like this: sfdx force:mdapi:deploy -d packages The packages folder ...
user avatar
  • 433k
13 votes
Accepted

How to push code to production with Visual Studio Code & DX

You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange ...
user avatar
  • 433k
13 votes
Accepted

How do I reset the SFDX CLI Runtime Global Configuration Values?

I had struggled to find this for a bit as I missed the section discussing this in the docs. I realized that the answer was in the same documentation CLI Runtime Configuration Values but was not ...
user avatar
12 votes
Accepted

"Cannot set property color of #<CLI> which has only a getter" when running sfdx commands

We had an auto release with a bug. We've rolled it back. Please run sfdx update and ignore the one time error you receive. The team is already performing a retro to understand how this got out. ...
user avatar
12 votes

SFDX: Grant type not supported

The fix for me was to use the URL that the dev org redirected to after logout. So I: Logged into the dev org Logged out of the dev org Copied the URL Executed this command in the terminal: sfdx ...
user avatar
  • 283
12 votes

How to sign a SFDX Plugin?

If you need to install automatically your plugin, like in a Dockerfile or in a CI process, you can use the following line : echo 'y' | sfdx plugins:install yourpluginname
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible