question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sfdx force:source:deploy with specified manifest having specific fields deploys everything in the local object folder

See original GitHub issue

Summary

When using the org development model, the salesforce cli will deploy the entire object file if you specify a package.xml specifying child components of that object (ValidationRule,CustomField,etc.).

Steps To Reproduce:

Scenario: You want to deploy a single custom field from your workspace (that is in dx format) to a Sandbox (org development model).

  1. You make a package.xml in the manifest folder named package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Account.MyCustomField__c</members>
        <name>CustomField</name>
    </types>
    <version>46.0</version>
</Package>
  1. I then run the following command to deploy the custom field to the sandbox:
sfdx force:source:deploy -u myuser@example.com  -x manifest/package.xml -w 10

Expected result

I would expect that the cli zips up that specific custom field and deploys it to the target org, with the below package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Account.MyCustomField__c</members>
        <name>CustomField</name>
    </types>
    <version>46.0</version>
</Package>

Actual result

The cli generates an object file with every single component in my local directory related to the custom object (fields, record types, etc.), and creates the following (incorrect) package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <types>
    <name>CustomObject</name>
    <members>Account</members>
  </types>
  <types>
    <name>CompactLayout</name>
    <!-- all local account compact layouts -->
  </types>
  <types>
    <name>FieldSet</name>
    <!-- all local account field sets -->
  </types>
  <types>
    <name>CustomField</name>
    <!-- all local account custom fields -->
  </types>
  <types>
    <name>ListView</name>
    <!-- all local list views -->
  </types>
  <types>
    <name>RecordType</name>
    <!-- all local record types -->
  </types>
  <types>
    <name>ValidationRule</name>
    <!-- all local validation rules -->
  </types>
  <types>
    <!-- all local web links -->
    <name>WebLink</name>
  </types>
  <version>46.0</version>
</Package>

It then proceed to deploy all of that metadata instead of the single custom field that should have been deployed.

Additional information

The only workaround I have is to add all of the unwanted components to the forceIgnore file which is not reasonable for hundred to thousands of components when I want to deploy a single field.

SFDX CLI Version:

sfdx-cli/7.20.1-d88ae4707c darwin-x64 node-v10.15.3

SFDX plugin Version:

@oclif/plugin-commands 1.2.2 (core)
@oclif/plugin-help 2.2.1 (core)
@oclif/plugin-not-found 1.2.2 (core)
@oclif/plugin-plugins 1.7.8 (core)
@oclif/plugin-update 1.3.9 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/sfdx-trust 3.0.5 (core)
analytics 1.2.1 (core)
generator 1.1.1 (core)
salesforcedx 46.10.2 (core)
├─ force-language-services 46.14.0 (core)
└─ salesforce-alm 46.13.0 (core)

sfdx-cli 7.20.1 (core)

OS and version:

ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G87

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:16
  • Comments:26

github_iconTop GitHub Comments

9reactions
dmgerowcommented, Nov 13, 2019

@clairebianchi more importantly, there are many times where you may have parallel projects going live at different times with some overlap on objects.

For example, if Team A is implementing a quoting solution and team B is implementing a field service solution, both teams will be adding or updating different metadata on the Account object. Rather than trying to merge every change that is introduced upstream in a QA environment which can be tedious with XML documents, we should be able to trust that if we specify a single CustomField to be deployed that the entire object is not deployed.

Since it is deploying more than what is specified in the package manifest, the release manager may be unknowingly overwriting a larger number of changes on the related object even though the manifest does not indicate it.

5reactions
payensa-sfcommented, Nov 28, 2019

Hi @clairebianchi this behaviour should also apply to the command force:source:convert -x which is currently keeping the whole object in the target folder even when you only specified a single part of it. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

source Commands | Salesforce CLI Command Reference
Use the source commands to push and pull source to and from your scratch orgs, to deploy and retrieve source to and from...
Read more >
Deployment to Production Org using VS Code
I read different blogs and found that we can use the command " sfdx force:mdapi:deploy " for the deployment. But, I didn't get...
Read more >
SFDX Source Deployment Vs Metadata API Deployment
Project folder structure is different. 2. In place of a single large metadata file, source format has individual metadata files for ...
Read more >
salesforce/plugin-source
To build the plugin locally, make sure to have yarn installed and run ... npm install -g @salesforce/plugin-source $ sfdx COMMAND running ...
Read more >
Salesforce CLI Command Reference ...
If you specify this parameter, don't specify --manifest or --metadata. ... class and the objects whose source is in a directory:$ sfdx force:source:deploy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found