Hot answers tagged

74 votes
Accepted

Two SFDX project folder structure questions

Before answering Keith's specific questions, I'd like to set the stage by describing the fundamentals of Salesforce DX "Projects", "Package Directories", and the "Default Package Directory". ...
user avatar
45 votes
Accepted

Visual representation code coverage in VSCode

In VS Code in your DX project, try clicking the three horizontal lines icon in the bottom status bar. If you have all the configurations setup correctly (which from your post, it looks like you do), ...
user avatar
  • 4,732
27 votes
Accepted

"Java runtime could not be located" when starting VSCode with the Salesforce Extensions

There are explicit details on the steps required for this in How do I configure the version of Java that the Apex Language Server uses? By default, VS Code attempts to locate your local Java ...
user avatar
23 votes

SFDX - No org configuration found for name

It may be a problem with aliases. I have mistakenly created an alias: DevHub=me@salesforce.com Then, not aware of consequences I created an alias again, in the way I wanted it in the first place: ...
user avatar
20 votes
Accepted

Log to console in a Lightning Web Component

You are most likely encountering ESLint errors in VS Code. As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or ...
user avatar
  • 29.2k
20 votes

Deploy lightning web component is getting failed with error - "--json --loglevel fatal ended with exit code 1"

I was also facing the same error but did not find anything here. If your deployment is failing, so you need to go to your developer org, setup --> Deployment Status Settings Here you will find the ...
user avatar
19 votes
Accepted

LightningComponentBundle "Not available for deploy for this API version" error

Looks like I have found already a culprit here. It is very important to check sourceApiVersion property of project.json configuration. Looks like this value was 44.0 in my project. Probably because ...
user avatar
  • 13.4k
19 votes

How to get custom object fields displaying in code completion in VS Code

Autocomplete depends on the metadata cache. To fix this, go to View > Command Palette (Ctrl-Shift-P), and type in "sobject". You should see a command "SFDX: Refresh sobject definitions." After that ...
user avatar
  • 439k
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,732
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
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
  • 439k
13 votes
Accepted

sf:INVALID_OPERATION: INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations

UPDATE 9/2019 As of Summer '19 v46.0, force:source:deploy now works when deploying to production, and you'll no longer get that testLevel error message. You can set the test level using the -l flag ...
user avatar
  • 4,732
11 votes
Accepted

No Option for "SFDX:Authorize an Org" command in VS Code Command Palette

Oh, I know the answer. You have to create a project first. Then and only then the other commands will become available for you Well, yeah. That's the answer. But just to make it cleaner for you. All ...
user avatar
11 votes

VSCode Lists Erroneous Apex Problems

The issue was the enable-semantic-errors setting under Settings -> extensions -> Salesforce Apex. Unchecking this setting solved my problem. It's currently in beta. I hope this saves someone a little ...
user avatar
10 votes
Accepted

The max apiVersion is 44.0 error

UPDATE Just got an update that the Spring '19 pre-release signup link is now live. You can access it on this link. You are getting this error because the LWC project expects a version 45.0 (Spring '...
user avatar
  • 29.2k
10 votes

Salesforce CLI is not installed - it ain't so

There appear to be two separate issues here: SFDX must be in your PATH environment variable. That is, the full path of the bin subdirectory where the sfdx executable lives. You'll likely need to ...
user avatar
  • 87.4k
10 votes

How to delete a Lightning Web Component?

Make sure that you have the most updated CLI version. On your terminal or command line use this: sfdx force:source:delete -p <path-to-the-component-folder-on-your-machine> It will ask you if ...
user avatar
10 votes
Accepted

Running unit test class from VSCode

You have three options for this. Run Invoke Apex Tests Command You will be prompted for a Test class name or Run all. From Test Window Edit: Added screenshot for Test Window. You will find a list ...
user avatar
  • 10.9k
10 votes
Accepted

How to format Apex code more flexible than with Prettier

Prettier by design does not really allow customization of the formatting, this is why it is an "Opinionated Source Formatter". For Apex, your formatting options are limited to the following ...
user avatar
  • 2,271
9 votes
Accepted

No sfdx-project.json found in the root directory of your open project. Open a Salesforce DX project in VS Code

You're missing a configuration file for some reason. Try the following. Close all files and folders in Visual Studio Code, then close it entirely. Create a new folder in your project directory ...
user avatar
  • 439k
9 votes
Accepted

SFDX: Is it possible to push to a sandbox from VS Code?

You need to use the force:source:deploy command (not available in the UI, as far as I can tell). The basic syntax is as follows: sfdx force:source:deploy -p source-dir/ -u username-or-alias This ...
user avatar
  • 439k
8 votes
Accepted

Unable to Retrieve Source from Sandbox

The activation event for Salesforce's official extension is it looks for the file sfdx-project.json file in the workspace. Hence make sure you have the sfdx-project.json in the project workspace root ...
user avatar
8 votes
Accepted

Invalid decorator usage. Supported decorators (api, wire, track) should be imported from "lwc"

You must add them to your import statement. Youโ€™re using @track, so you should have the following: import { LightningElement, track } from 'lwc'; You can read more about reactive properties, how to ...
user avatar
8 votes

SFDX Question. Can source:status be used in sandboxes?

The source tracking feature for developer and developer pro sandboxes is GA from the winter 21 release. You will need to first enable this in DevHub and then refresh the sandbox from PROD to get this ...
user avatar
8 votes
Accepted

Apex Code - Region for as C#

#region and #endregion define a code folding unit. The Apex extensions for Visual Studio Code added support for these directives in 2018. The directives must be located in comments; #region ...
user avatar
  • 87.4k
7 votes

Two SFDX project folder structure questions

Based on the webinar mentioned in the comment, breaking the components out into multiple folders that have meaningful names is the way to go. For example, they suggest using the managed package ...
user avatar
  • 131k
7 votes

Can I use git repo in old format and vscode in new source format?

That's similar to what we do now and... no, it doesn't work, at least not well. If you do this, you will continue to make more work for yourself, and you will likely "never" get in to DX format. ...
user avatar
  • 439k
7 votes
Accepted

vscode with sfdx plugin eating too much memory

Looks like this is a well known issue with the Salesforce vscode extension and Salesforce is working to fix this . You can track down here https://github.com/forcedotcom/salesforcedx-vscode/issues/...
user avatar
7 votes
Accepted

SFDX - No org configuration found for name

Deleting folders "tools", "typings" and the file "sfdx-config.json" and then close and open vscode solved the problem.
user avatar
  • 529
7 votes
Accepted

Retrieving Metadata from Org using VS Code and CLI results:- MaxListenersExceededWarning: Possible EventEmitter memory leak detected

It's a known issue in the CLI and Salesforce is working towards the fix. The fix is scheduled to go out today (USA PST hours) Check th details here below https://github.com/forcedotcom/cli/issues/...
user avatar

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