Cli: Metadata from Sandbox always retrieved with latest API version instead of following sourceApiVersion

Created on 30 May 2019  路  6Comments  路  Source: forcedotcom/cli

Summary

Metadata Retrieval from a Sandbox always uses the latest API version (right now, 45.0) instead of using the sourceApiVersion specified in sfdx-project.json.

Steps To Reproduce:

  1. Use an old API version in sfdx-project.json, for example:
{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "43.0"
}

  1. Authorize with a Sandbox

  2. Right click on a custom object in the objects directory, click SFDX: Retrieve Source From Org

Expected result

The retrieved custom object should have their metadata structure based on the sourceApiVersion.

Actual result

The retrieved custom object has their metadata structure based on version 45.0. One thing that is easy to check is the existence of the enableLicensing node in the metadata XML, which does not exist in version 43.0.

Additional information

VS Code Version: 1.34.0

SFDX CLI Version: sfdx-cli/7.6.0-28071a499b

OS and version: Windows 10/Arch Linux

bug

Most helpful comment

Just came across this issue. It's pretty tough to deal with as the API version has a BIG impact and needs to be consistent across dev machines and CI environments.

@clairebianchi any chance this is in the backlog?

All 6 comments

@dangmai, does it change the behavior if you set the API version at the DX config level instead of at the project config level?

I'm not suggesting this is ideal, just curious if this is an alternative that might work.

sfdx force:config:set apiVersion=43.0 which modifies the .sfdx/sfdx-config.json file. I know that I do that for pre-release versions of DX to use it on orgs that haven't been updated yet.

@aheber that's a good idea, thank you! I'll try that to see if it can be a work around for this issue.

@dangmai did the workaround work?
Also can you please send us the command you are running? this sounds like a bug want to make sure we fix it on the correct command

Yup that workaround does work. The commands I use is:

sfdx force:config:set apiVersion=43.0
sfdx force:source:retrieve --sourcepath /home/xxx/repo/force-app/main/default/objects/Some_Object__c

The result object no longer contains the enableLicensing node. However I still think the sfdx-project.json config should be followed by default, since there's a good chance that the .sfdx is put into the VCS ignore file and this workaround needs to be applied manually to every dev machine.

Just came across this issue. It's pretty tough to deal with as the API version has a BIG impact and needs to be consistent across dev machines and CI environments.

@clairebianchi any chance this is in the backlog?

+1

Was this page helpful?
0 / 5 - 0 ratings