23

All the tutorials I have seen referencing the use of Visual Studio Code for Salesforce development imply that it is used in conjunction with SalesforceDX. It is my understanding DX is a relatively new development technique/workflow for SF... git, easier deployment, component based instead of whole org, etc. In my current environment, SalesforceDX has not been adopted.

Is it possible to use Visual Studio Code in that "traditional/older" development workflow without DX specifically? My assumption is that it will be similar to how Mavensmate and Sublime would have functioned.

10

There are some Visualstudio code extensions that can work without needing SFDX workflow .Note that current official plugin also supports working without DX scratch org support .

I created my own extension to supplement salesforce official visualstudio extension pack , feel free to use that .Note that you will need salesforcedx cli and the plugins(Does not mean you need DX scratch org capabilities or hub org). It makes saving apex ,vf and lightning components faster and works along side of the official extension .

ForceCode is another option.

There is also a mavensmate extension package for building salesforce applications .

There are also bunch of few more extensions that you can try and see if it works for what you want .

  • would you say that Visualstudio code + ForceCode is better than Eclipse + ForceIDE.com? And if so, in what regard? I have been doing some light developing with forceide and eclipse, but am currently setting up a new system, was wondering if I should switch right away. – Fabian Bosler Aug 6 '18 at 8:54
  • 1
    @FabianBosler I'd definitely suggest moving away from ForceIDE since v2 has been officially deprecated and Salesforce is officially stating VSCode is the way forward. [developer.salesforce.com/blogs/2018/02/… About Salesforce Extensions for VS Code) – torpy Aug 6 '18 at 19:53
13

Looks like there is a better way now: Org Development Model with VS Code

This link provides detailed instructions for using the "SFDX: Create Project with Manifest" command which enables connection to a regular sandbox (not a scratch org). This approach gives the ability to push and pull metadata without going through a long multi-step process on every code edit.

This still requires two steps (save file locally and push the entity to Salesforce), but eliminates the requirement to zip, convert and deploy on every save.

If you are receiving errors after following the steps in the above link, here are some additional resources:

Error: “UNSUPPORTED_API_VERSION: Invalid Api version specified on URL.” can be addressed by manually overriding the api version within SFDX itself (separate from "sfdx force --version" and "sfdx plugins" commands). In order to manually set SFDX version, use following command: "sfdx force:config:set apiVersion=44.0" or whatever is appropriate api version. See “UNSUPPORTED_API_VERSION: Invalid Api version specified on URL.”

Also, if you are receiving the "EISDIR: illegal operation on a directory, read" error, this appears to be due to a race error when retrieving entities stored in sub folders such as Lightning components. This can be addressed by removing items that use subfolders in your package file for the initial retrieve and then adding them back in per "EISDIR: illegal operation on a directory, read"

  • 2
    wight waant to add the details from the link - otherwise it will be flagges as a 'link only answer' and the link might become unavailable some day, so best to incldue the essentials. – glls Oct 15 '18 at 17:24
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – glls Oct 15 '18 at 17:24
  • @glls Really? There is way too much content on that page to copy here and it is a better answer than was previously posted due to the release of new functionality. – Mike Paisner Oct 15 '18 at 17:54
  • 1
    As stated earlier - i did not downvote your question... I understand that you would like to contribute, however, consider reading How to Answer in order to generate a useful one for the community. Thanks – glls Oct 15 '18 at 18:22
  • 2
    I think Mike's fleshed this out to make it useful. Important to remember SFDX can refer to both the workflow/methodology (using scratch orgs) and the software itself. This new feature does appear to be Salesforce's official answer to the question of "how do I do traditional sandbox development with Visual Studio Code". – David Reed Oct 15 '18 at 18:28
4

To use sfdx in classic Dev sandbox developement model, follow the below steps sequentially:

1. Create a sfdx project

  • sfdx force:project:create -n myproject
  • Tip: Connect to your org if you haven't already
  • sfdx force:auth:web:login -s -r https://test.salesforce.com -a <alias>

2. Retrieve your source code using force:mdapi:retrieve

3. Convert mdapi metadata into sfdx metadata structure using force:mdapi:convert

  • Unzip the retrieved package
  • sfdx force:mdapi:convert -r <path to source>
  • by default this should end up in your force-app folder

4. Do your development in VS code

5. Once the development is done,convert sfdx metadata back to mdapi structure: force:source:convert

  • sfdx force:source:convert -r <path to source> -d <path to output dir> -n 'My Package'

6. Finally, use force:mdapi:deploy to deploy your code

  • sfdx force:mdapi:deploy -d <path to source>/ -w -1 -u <alias>

Because it is a sfdx project, you will get the benefit of all the SFDX extensions like CLI, apex, lightning and visualforce support in VS Code. You can find more details about these commands in the development guide

  • While this works, it seems like this a very inefficient process for doing development. Downloading, unzipping and converting files to make sure I have the latest code? And then converting and deploying in order run my code? – Mike Paisner Oct 5 '18 at 16:46
  • 1
    Looks like there is a better way now: github.com/forcedotcom/salesforcedx-vscode/wiki/… – Mike Paisner Oct 8 '18 at 23:40
  • @MikePaisner that works if you have to work with code but if you have to retrieve a different kind of metadata, you need to convert it. – DarkSkull Feb 7 at 18:06
  • I am able to retrieve lots of different types of metadata besides code such as Objects, Pages, Layouts, Flows, SharingRules, Workflows, etc using the approach I linked to. I generally don't modify or deploy other metadata types using this approach, but it is super useful for doing searches of metadata. I can use Edit->Find in Files and search all the metadata I've retrieved. For deploying metadata, I prefer ANT. – Mike Paisner Feb 8 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.