Search code examples
visual-studio-codesalesforcesalesforce-lightninglwc

How to import LWC component from ORG to VSCODE?


I am having some difficulties importing LWC components from org to VSCODE. Is it the right way? Here's what I am following -

  1. Created a new Manifest project.
  2. Connected to my sandbox org (not scratch).
  3. Right clicked on Package.xml under Manifest & selected - Retrieve source in Manifest from Org.

enter image description here


Solution

  • Yes, should work. Does your package.xml contain

    <types>
        <members>*</members>
        <name>LightningComponentBundle</name>
    </types>
    

    Are you sure you're connecting to right org? If you Ctrl+Shift+P -> Open default org, do you land in the sandbox that contains this component? Any errors when you retrieve? sfdx is installed ok?

    Do you see your component if you open developer console, query tab, tick the Tooling API checkbox(!) and run SELECT DeveloperName FROM LightningComponentBundle?

    If all else fails you can query the bodies with Tooling API's SELECT Id, FilePath, Format, Source FROM LightningComponentResource but it should "just work"...