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
Rebecca Johnson 2Rebecca Johnson 2 

Delete Apex Classes without eclipse? Or undo deletions from yesterday?

Yesterday, I was attempting to delete some unneeded objects, and finding that I needed to delete Apex Classes and other things that were using them. I stopped work, planning to pick it up the next day.

Overnight, our environment changed: it became a production environment. Something went live and suddenly I found myself unable to delete Apex Classes.

The problem is that now the environment is broken. We can't even add a new account. The partial deletions I did yesterday are messing us up. Here is the error I get when I try to add a new Account:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger RollupServiceTest3Trigger caused an unexpected exception, contact your administrator: RollupServiceTest3Trigger: execution of BeforeInsert caused by: line 13, column 45: trigger body is invalid and failed recompilation: Dependent class is invalid and needs recompilation: rollupservice: line 87, column 37: Dependent class is invalid and needs recompilation: rollupsummariesselector: line 62, column 55: Dependent class is invalid and needs recompilation: RollupSummaries: line 30, column 38: Invalid type: fflib_SObjectDomain

This is related to a package called Declarative Lookup Rollup Summary Tool (DLRS), created by AndyInTheCloud and available on github. I have emailed him but I have little hope of a response.

Background information: what I originally did was install the DLRS source code. Then I realized that wasn't the package I needed, and I figured out how to install it and did so. Then I noticed that the source code and actual package installation led to duplicate objects. So I thought I would clean it up by removing the source code objects. And that is what I did yesterday.

At first I thought that what I needed to do was to finish up my job of deleting the unused objects. And so I searched the web and it seemed that using the IDE in Eclipse was the solution. I don't have access to Eclipse. So I thought I would ask here how to delete Apex Classes from production without Eclipse.

But now I wonder if I shouldn't try to undo yesterday's deletions.

Has anyone had similar experiences? I have completely broken production and I need to fix it.

Edgar MoranEdgar Moran
The recompilation part happened to me sometime ago, what it worked for me was:

- In Eclipse ot Mavensame (IDE you are using), you need first clean the code or retrieve the last version from Salesforce, this allows you to have the metadata in your computer and to have a copy of all clases and triggers.

- Second should be to create a Sandbox environment, thi ssandbox actually will have the same configuration in configuration and code
- Fix everything in your sandbox doing this:

1. Try to create the same rollup rule you deleted and attempt to create and activate the Class (the rollup tool will attemp to deploy the same class that maybe you deleted at the beggining)

2. Try to save the code in your sandbox if there were any changes, if there'are errors should be easy to fix those in there.

3. If everything was fixed in Sandbox, you should deploy the last version of apex classes and triggers with ANT or even with a Change Set selecting the test clasess included in the last version of your code.

4. If no errors showed up you should have the production environment working again.

NOTE. Highly recommended always install packages that plays whit apex classes or other integrations in sandbox environments instead to install it directly in production :)

Hope this helps, Best!
Rebecca Johnson 2Rebecca Johnson 2
Thank you, Edgar.

Your notes sound very similar to these instructions:

I now have IDE running in Eclipse! I am brand new to this environment. I created a project and input my credentials for my production environment. Now I am looking at the trigger I want to delete.

But, I have a learning curve. The instructions say: 
2. Connect to the Sandbox Instance using the IDE and find the class or trigger that you want to delete.

Well, I'm not connected to a sandbox, I'm connected to production. So right now I'm creating a new sandbox and waiting for that to finish. Then I'll connect to that sandbox and carry on with the rest of the instructions. I think I'm on my way. Thank you!