function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Flywheel DevFlywheel Dev 

Apex Class and Trigger Deletion CLI Failing without Error Message

I am attempting to delete the following from a production environment using the CLI:
- An Apex class
- The test class for that Apex class
- 2 Apex triggers that I have successfully disabled in production using the Salesforce CLI in VS Code

I am running into an issue now where I am unable to delete these files from prod. I have tried creating a manifest file within my project and creating a new project with manifest.

For the sake4 of looking at something, I have tried deploying the manifest deleting the triggers using the following CLI command:
 
sfdx force:source:deploy -x manifest/deleteApex.xml --testlevel RunSpecifiedTests --runtests testMethod

Where TestMethod is a test method that I know passes. This worked before when I was simply changing the triggers' statuses to Inactive, but it is no longer working now that I am trying to change the statuses to Deleted.

More frustrating, I am not getting any sort of error information to debug with. This is what I get:
 
*** Deploying v54.0 metadata with SOAP API v53.0 connection ***
Deploy ID: [Deploy ID]

=== Component Failures [0]
Type  Name  Problem
────  ────  ───────


=== Test Results Summary
Passing: 0
Failing: 1
Total: 1
Time: 0
ERROR running force:source:deploy:  Deploy failed.



 
AnkaiahAnkaiah (Salesforce Developers) 
Hi ,

An Apex Class or Trigger must be removed from a production instance if it's blocking a deployment or is no longer needed. Since Apex code can't be modified directly within a Production organization, it requires steps using Developer tools, like ANT Migration Tool.
NOTE: This is the only way an Administrator or Developer can disable or remove Apex in Production.

Refer the below article for steps to delete the trigger/apex class from production.
https://help.salesforce.com/s/articleView?id=000328218&type=1

https://www.salesforceben.com/way-to-delete-apex-classes-from-production/

If this helps, Please mark it as best answer.

Thanks!!
Flywheel DevFlywheel Dev
I am now struggling with the ANT Migration Tool, but this is forward momentum. Thank you.
Gabriel Kremer 35Gabriel Kremer 35
A few more possibilities:
- Salesforce Workbench
- SF CLI
- ANT Migrant
- Extension in VSC with destructiveChanges.xml and only clicks
- some other solutions might be out there. (Copado, Gearset and so on via CI/CD)