It is fairly effortless to delete an unwanted apex class or trigger in a Sandbox Environment. On the other hand, Unlike the Sandbox environment, it is not possible to delete code from Production environment just by clicking in the DELETE Button. Here are some methods that may work for you. NOTE: Please consider that deleting or removing code from Production affects the code coverage of the Org. Ensure that the coverage is above 75% which is the salesforce standard.
Comment the Code
The easiest way would be to comment the code. This method obviously doesn’t delete the apex class but it is a relatively quick fix. The code is commented in the Sandbox Environment and deployed to Production.
We are going to delete MyRestResource.apxc
- Create an xml file and save it as package.xml.
- Enter the following snippet into the xml file and save it. (If required update the version to the latest one).
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <version>51.0</version> </Package>
- Create another file, copy the below text and save it as “DestructiveClasses.xml”. to delete multiple files, add more <members> nodes and update the class name into the nodes. To delete triggers, add a <types> node and enter <name> as ApexTrigger.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <version>51.0</version> <types> <members> MyRestResource </members> <name>ApexClass</name> </types> </Package>
- Save the two files and zip them together. Name the zip file as package.zip.
- Login to Workbench and select Migration and go to Deploy, upload the zip file and enable ‘Rollback On Error’, ‘Single Package’ and ‘Check Only’. Click next and deploy.
- If the validation is Success, Uncheck the “Check only” checkbox and continue the deployment.
- Once you receive the success message, the class will be deleted.
Using the steps mentioned in the blog above, we hope you are able to extract the code from Production org of your Salesforce.
We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, please contact us at firstname.lastname@example.org.
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.
Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.
The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.
For more information on our Salesforce products and services, contact us at email@example.com. We will be glad to assist you.
- How to Display Toasts or Notices using Lightning : NotificationLibrary
- How to Add or Remove CSS style from the component/element during runtime or dynamically
- Adding Utility bar in a Salesforce lightning application
- How to Notify User about Unsaved Changes on the UI using Lightning Component
- Add Delete Row Dynamically In Salesforce Lightning
- Salesforce – How to get row index of lightning table rows