Salesforcedx-vscode: SFDX: Retrieve Source from Org command does not retrieve new files

Created on 18 May 2020  路  15Comments  路  Source: forcedotcom/salesforcedx-vscode

Bug 1175 was closed without the bug being fixed.

Steps To Reproduce:

  1. Download Source from Org.
  2. Create new apex class in browser.
  3. Retrieve Source From Org

Expected result

The new class appears in the explorer view.

Actual result

The new class does not appear.

My package.xml




ApexClass



ApexComponent



ApexPage



ApexTestSuite



ApexTrigger



AuraDefinitionBundle



LightningComponentBundle



StaticResource

47.0

Version of VSCode:

Version: 1.45.1 (user setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.17763

Most helpful comment

@smaddox-sf This is not working as you described and as @ElsonPaim said, this works in my sandbox and production org, but for some reason it doesn't work on Trailhead orgs. Here's what I did:

  1. Created trailhead playground and installed a package
  2. VSC Code > Create project from manifest
  3. Authorized the org
  4. Right click on the package.xml which specifies the wildcard to pull all apex classes, and clicked "Retrieve from manifest"

Nothing was retrieved.

If I follow these steps in a prod or sandbox org, it works.

All 15 comments

I don't know if its a bug in my case I need to do a retrieve in the package when a need a new file from org, the retrieve button just refresh exiting files on project

Hi @leefranke - This is behaving as designed. We only pull existing content, not new files. If you want to pull new files you should perform a retrieve using a package.xml that has either all apex classes or the specific classes you want to retrieve.

The file I'm attempting to pull exists. I created it via the web.

My package.xml has all the ApexClasses.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>ApexClass</name> </types> <types> <members>*</members> <name>ApexComponent</name> </types> <types> <members>*</members> <name>ApexPage</name> </types> <types> <members>*</members> <name>ApexTestSuite</name> </types> <types> <members>*</members> <name>ApexTrigger</name> </types> <types> <members>*</members> <name>AuraDefinitionBundle</name> </types> <types> <members>*</members> <name>LightningComponentBundle</name> </types> <types> <members>*</members> <name>StaticResource</name> </types> <version>47.0</version> </Package>

Right clicking on the classes subfolder and 'SFDX: Retrieve Source from Org' does not add the existing class.

Or are you saying that once the initial authorize and retrieve is done those are all the files I have to work with? If any new files come into existence after that I have to do the entire process over again?

Hi @leefranke - This is behaving as designed. We only pull existing content, not new files. If you want to pull new files you should perform a retrieve using a package.xml that has either all apex classes or the specific classes you want to retrieve.

It doesn't make sense, unless it have to happen only in Trailhead (or Dev) orgs, because in the Orgs of the company that I work it works normally.

@smaddox-sf This is not working as you described and as @ElsonPaim said, this works in my sandbox and production org, but for some reason it doesn't work on Trailhead orgs. Here's what I did:

  1. Created trailhead playground and installed a package
  2. VSC Code > Create project from manifest
  3. Authorized the org
  4. Right click on the package.xml which specifies the wildcard to pull all apex classes, and clicked "Retrieve from manifest"

Nothing was retrieved.

If I follow these steps in a prod or sandbox org, it works.

Hi I know that you all have a lot on the roadmap, but I am just adding my name to the list here. I am running into the same issues as everyone else. Works in paid orgs, but not personal dev envs. 馃.

Something strange: all Apex classes in my org show in the results array in the ApexClass.json file.

Hi all, I'll be seeing if I can get to the root issue everyone is having. This is what I've done successfully so far:

  1. Create a new project with manifest
  2. Authorize a brand new trailhead org
  3. Create a new apex class in the trailhead org
  4. Used the org browser to successfully retrieve the new class
  5. Used the default manifest with the "create project" command to successfully retrieve the new class

My CLI version: sfdx-cli/7.63.0-c897e8bb1a darwin-x64 node-v10.20.1
My Extension version: 48.21.0

For folks that are trying to retrieve classes that are part of a package, would someone mind elaborating on the kind of package the classes are a part of? @leefranke in your case you're creating a brand new apex class like I did and you shouldn't have to go through another setup process. Have you tried using the org browser sidebar to do the initial retrieve of your new class?

To add additional clarification for anyone trying this, right clicking on the classes folder in your local project and selecting "Retrieve Source from Org" will not retrieve new classes - it retrieves updated versions of the classes already in your local project under that folder. That was how it was designed but we acknowledge how that might be confusing. If you open the org browser (cloud icon in the vscode toolbar) you can click on the cloud icon next to "Apex Classes" to retrieve all the classes in your org, or retrieve individual classes by clicking the button next to their names if you do not want to use a manifest.

Hi @brpowell glad to see this case got reopened! The 5 steps that you did so far work for me as well. I am able to retrieve all classes that I or someone inside my org has created in vscode or the dev console.

I am running into issues only on APEX that is imported from a package.

  1. When working on the LWC trailhead superbadge you have to download package 04t6g000008SZzHAAW (this package contains apex classes)
  2. I was able to install the package as I normally without errors.
  3. I am able to view and modify the apex classes in the dev console
    image

  4. I am unable to view/modify/download the apex classes in vscode
    image

Sorry for the image sizing, for some reason I can not get them to be smaller, but I wanted to show you what I am working with.
My CLI Version: sfdx-cli/7.61.0 darwin-x64 node-v14.4.0

Thanks!

@handlerda exactly what I was looking for thank you! The issue is that the org browser loads the components based on whether they are editable or not and it gets this information from the metadata api. In Winter 20' the metadata api added values to specify if a component is part of an unlocked package so we can update the org browser to check those values. We'll publish a fix for that.

Hi guys, I've got the same issue..

  1. Create new Trailhead.
  2. Install the package.
  3. Create new project with manifest.
  4. Retrieve Source from Org.

Nothing happens.. Even in the Org Browser it gives nothing.. Does anyone have any idea what is going on?

Hi @justKev93 - The org browser fix is being released this week (likely tomorrow) so you should be able to see the components in the package once that is out. Are you having issues trying to retrieve another way?

Hi @brpowell, I have also tried using the manifest/package.xml with the defined metadata types that are retrieving nothing. I am not really sure how the Org Browser works. I am basically trying to fulfil the "What do I need to know about the unlocked pacakage" section of this help link to be used for the Lightning Web Components Specialist Superbadge.. So far it has been rather unhelpful.

@justKev93 When the org browser fix goes out tomorrow that'll be an easy way to retrieve components without a manifest. You can read more about it in the user guide here. In the meantime can you share the contents of the manifest you're using? And is this how you're trying to retrieve with it?

Screen Shot 2020-07-08 at 3 11 50 PM

@brpowell, that is correct. I created a standard project with a manifest, so this is the default one. The manifest is below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>ApexClass</name> </types> <types> <members>*</members> <name>ApexComponent</name> </types> <types> <members>*</members> <name>ApexPage</name> </types> <types> <members>*</members> <name>ApexTestSuite</name> </types> <types> <members>*</members> <name>ApexTrigger</name> </types> <types> <members>*</members> <name>AuraDefinitionBundle</name> </types> <types> <members>*</members> <name>LightningComponentBundle</name> </types> <types> <members>*</members> <name>StaticResource</name> </types> <version>49.0</version> </Package>

The fix for retrieving unlocked package metadata through the Org Browser was released as part of version 48.24.0.

The only other question left is on retrieving unlocked package metadata using the package.xml. When you work with packaged metadata, regardless of the type of package, you'll need to explicitly add the name of the file/metadata to the package.xml. The * will not cover those pieces of metadata.

If my unlocked package is installed in my org and I want to retrieve an Apex Class from it my package.xml will look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>ExternalNlpDocumentEmotion</members>
        <name>ApexClass</name>
    </types>
    <version>49.0</version>
</Package>

I'm closing this now since the last question has been answered, thanks for the feedback.

Was this page helpful?
0 / 5 - 0 ratings