2

It is ok to say 'forget it, it doesn't work with a sandbox'. So I have successfully created a project and done a retrieve source from org. I'm focusing on APEX classes for the moment. I can open, edit, save, and update the sandbox copy of the class with a deploy source to org.

Here's the strange thing:

If I create a new class in my sandbox and then do a retrieve source from org the new class is not picked up. If I create the class in VS Code and do a deploy source to org the new class is pushed over to the sandbox. If I update the class in the sandbox and do a retrieve OR update the class in VS Code and do a deploy then everything works as I would expect.

I initially thought is was this 'source of truth' idea but I don't think so. Thoughts?

  • sfdx force:source:retrieve --sourcepath c:\Users\Dad\Documents\VSCode\DeanSand\force-app\main\default\classes\SiteRegisterControllerTest.cls-meta.xml === Retrieved Source SiteRegisterControllerTest ApexClass force-app\main\default\classes\SiteRegisterControllerTest.cls SiteRegisterControllerTest ApexClass force-app\main\default\classes\SiteRegisterControllerTest.cls-meta.xml sfdx force:source:retrieve --sourcepath c:\Users\Dad\Documents\VSCode\DeanSand\force-app\main\default\classes\SiteRegisterControllerTest.cls-meta.xml ended with exit code 0 – Dean Wooldridge Nov 12 '18 at 2:10
  • Just did a right click and Retrieve Source from Org – Dean Wooldridge Nov 12 '18 at 2:11
  • sfdx-cli/6.38.0-0d66175ccf (windows-x64) node-v8.9.4 – Dean Wooldridge Nov 12 '18 at 15:16
  • My VS Code extension was out of date. I did a reload and it showed up. Still, you might want to read my answer. – sfdcfox Nov 12 '18 at 15:17
  • 1
    right click when positioned over the manifest --> package.xml then do the retrieve and it pulls the new class – Dean Wooldridge Nov 12 '18 at 15:31
1

The sfdx force:source:retrieve command requires one of three parameters: a metadata file, a list of metadata objects, or a source path. The sourcepath option is generally the safest to use when working on a DX project to avoid accidentally pulling files you didn't mean to, without specifying a metadata file or potentially long list of file names.

The extension you're using presumes that you want to just pull the source for files you already have on your system. For other types of pulls, you can do this directly through the terminal. For example, to pull a specific class:

sfdx force:source:retrieve --metadata ApexClass:MyNewClass

The new CLI uses the same metadata types as the Metadata API, so you might want to start there for a reference of types, plus the sfdx help force:source:retrieve command for more information on how this command works.

If you don't have a menu option for retrieving specific files, you can click on the TERMINAL tab to open a new command prompt, then type in the sfdx command you'd like to use.

Alternatively, definitely use the Create Apex Class option from your context menu to create it locally then push it to the server. That's how the extension is configured to work, so it'd be easiest to just follow the path of least resistance.

Xi Xiao has also written a gist that you may find useful for commands you're likely going to want to get started.

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.