Activity Forums Salesforce® Discussions What are the different ways to delete apex Class from production in Salesforce

  • What are the different ways to delete apex Class from production in Salesforce

    Posted by Kirandeep on September 15, 2020 at 11:00 am

    What are the different ways to delete apex Class from production in Salesforce

    Sridhar replied 1 year, 4 months ago 6 Members · 5 Replies
  • 5 Replies
  • Anuj

    Member
    September 15, 2020 at 1:27 pm

    Hi,
    you can use Ant migration tool , workbench and Force.com IDE to delete classes and trigger from Production Org.

  • Sharath Chandra

    Member
    August 4, 2022 at 3:35 pm
  • vishakha

    Member
    October 22, 2022 at 6:44 am

    1. Install the Ant Migration Tool.
    2. Connect to the production instance and find the class or trigger that you want to delete.
    3. Retrieve the matching class or trigger and change the Status XML tag from Active to Deleted.
    4. Or, to disable the trigger, change it to Inactive (NOTE: Apex class Status can only be changed to "Active" or "Deleted," not "Inactive").
    5. Save the file.
    6. Zip the file, package.xml, and destructivechanges.xml.
    7. Deploy to production!

  • Shuvam

    Member
    June 23, 2023 at 11:34 am

    To delete an Apex Class from production in Salesforce, you've got a couple of options:

    1. Use the Metadata API: You can use tools that leverage the Metadata API, like Workbench or the Ant Migration Tool, to delete an Apex class. For this, you'd create a destructiveChanges.xml file specifying the classes you want to delete, and deploy that to your production org.
    2. Use an IDE: You can use an Integrated Development Environment (IDE) like Visual Studio Code with the Salesforce Extensions. You can delete the class in the IDE, and then push the changes to the server.
  • Sridhar

    Member
    June 24, 2023 at 11:31 am

    In Salesforce, there are several ways to delete an Apex class from a production environment. Here are a few methods:
    1. Salesforce User Interface:
    - Navigate to the Salesforce Setup menu by clicking on the gear icon in the upper-right corner.
    - In the Quick Find box, search for "Apex Classes" and select the "Apex Classes" option.
    - Locate the class you want to delete and click on the checkbox next to it.
    - Click the "Delete" button to remove the class. You may need to confirm the deletion.
    2. Salesforce Developer Console:
    - Open the Salesforce Developer Console by going to the Salesforce Setup menu, searching for "Developer Console," and selecting it.
    - In the Developer Console, click on the "File" menu and select "Open."
    - Choose "Apex Class" from the options and select the class you want to delete.
    - Click on the "Delete" button to remove the class.
    3. Salesforce Metadata API:
    - Use a Salesforce Metadata API tool, such as the Force.com Migration Tool or Salesforce CLI, to delete the Apex class programmatically.
    - Create a destructiveChanges.xml file and specify the Apex class to be deleted in the file.
    - Deploy the destructiveChanges.xml file to the production environment using the Metadata API.
    4. Salesforce Metadata Deployment:
    - Create a package.xml file that includes the Apex class you want to delete.
    - Use a metadata deployment tool, such as the Force.com Migration Tool or Salesforce CLI, to deploy the package.xml file to the production environment. Ensure that the destructive flag is set for the Apex class in the deployment file to indicate deletion.
    5. Change Sets:
    - If the Apex class is part of a change set that hasn't been deployed yet, you can remove the class from the change set in the Salesforce user interface. Go to the "Outbound Change Sets" section, open the change set, and remove the Apex class from the components list before deploying the change set.
    Remember, when deleting an Apex class, make sure to consider any dependencies or impacts it may have on other components in your Salesforce org. It's good practice to review and test the changes thoroughly before performing the deletion in a production environment. Additionally, ensure that you have appropriate permissions and follow your organization's change management processes when making modifications in a production environment.
    For salesforce training visit us at https://nareshit.com/salesforce-online-training/
    call us @ <b style="font-family: inherit; font-size: inherit; color: var(--bb-body-text-color);">8179191999

Log In to reply.

Popular Salesforce Blogs