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:delete does not work on production orgs

See original GitHub issue

force:source:delete fails and wouldn’t run on production orgs.

Steps to Reproduce:

  • Connect to any production org and attempt to delete any metadata (in this case attempting to delete a custom field)

sfdx force:source:delete -m "CustomField:testobject__c.Admin_Badges__c"

throws error: { “status”: 1, “name”: “sf:INVALID_OPERATION”, “message”: “INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations”, “exitCode”: 1, “commandName”: “SourceDeleteCommand” }

  • As above command failed with testLevel missing error, try providing testlevel and attempt the delete

sfdx force:source:delete -m "CustomField:trailheadapp__Trailhead_User_Data__c.Admin_Badges__c" -l RunLocalTests

throws error: { “status”: 1, “name”: “Error”, “message”: “Unexpected arguments: -l, RunLocalTests\nSee more help with --help”, “exitCode”: 1, “commandName”: “SourceDeleteCommand”, “stack”: "Error: Unexpected arguments: -l, RunLocalTests }

tried other possibilities with --checkonly flag etc… but none help. tried with latest and greatest cli & plugin version.

Couple other notes:

  1. The documentation from Salesforce is very Vague around this and needs correction as well. It doesn’t clearly state whether this is designed to work for production orgs or not.
  2. This command should also take manifest file (package.xml/destructivechanges.xml) to have scalable way to list components to delete. currently it seem like designed to accept only comma separated metadata components which is not viable.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cristiand391commented, Sep 30, 2021

This was fixed in latest v7.120.0, release notes: https://github.com/forcedotcom/cli/tree/main/releasenotes#71200-sept-30-2021

1reaction
shetzelcommented, Jul 1, 2021

@fransf-wtax - We first want to promote the source plugin to the production CLI core plugins. Once that work is complete the next scheduled work will be to add the source delete command to it, but also to support destructive changes as part of a source:deploy. My guess is it will be delivered in late July or early August.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Develop Against Any Org | Salesforce DX Developer Guide
Use the force:source:delete command to delete components from orgs that don't have source tracking, such as sandboxes. Run this command from within a...
Read more >
Deployment errors tips - Sfdx-Hardis - GitHub Pages
Go to target org, in Setup -> Deployment Settings -> Activate option "Allow deployments of components when corresponding Apex jobs are pending or...
Read more >
Scratch Org - Salesforce - Confluence - Atlassian
I had not closed VS Code down, I just re-opened it, but even doing a force:source:pull it says I was not in a...
Read more >
Develop Against Any Org with Visual Studio Code Tasks
You can run the command sfdx force:project:create -n myproj to scaffold a ... deleted from my org, as the force:source:push command might ......
Read more >
Metadata API Developer Guide
Troubleshooting. If your retrieve call times out or an error occurs, run this command: sfdx force:mdapi:retrieve -k path/to/package.xml.
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