Slaesforce FAQ

how to delete a class from salesforce production

by Kenya Bednar Published 2 years ago Updated 2 years ago
image

  • In dev org, right click desired class to delete
  • Select delete. Click yes or OK
  • Right click the Classes folder, then select Force.com > Deploy
  • Log in with Prod org credentials
  • In the deployment window, deselect everything but the Class you want to remove from Prod
  • Continue the wizard.
  • Class removed from Prod.

Remove Apex Class or Trigger
  1. Install 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. ...
  5. Save the file.

Is it possible to delete a class in Salesforce?

I am 99.999% sure that you cannot delete the class through the Salesforce Web interface. You cannot do it through Changesets. I believe that you have to use something backed by the metadata API such as the Force.com IDE or the Ant Migration tool with a destructiveChanges file.

Can I delete an apex class from a Salesforce production?

The Force.com migration tool (ANT) can take some time to learn how to use properly. Apex classes and triggers cannot be deleted from a Salesforce production declaratively, unlike in sandbox orgs. This is because security for Apex in Salesforce production orgs is greatly increased.

How do I delete a class in production?

You cannot delete a class in production directly. You will need delete the class from your sandbox and then deploy the deletions to your production org. When you deploy from sandbox to production, the missing classes will come up in red and you can choose to deploy these deletions to Production.

How to delete a class from the force server?

1) From Force.com IDE, select the class that you want to delete (Look for .xml extension ) 2) Open that .xml version of your class and change the Status tag to Deleted. 3) Right click and save the file. 4) Now select "SRC" folder and right click--->Select Force.com---> select Deploy to server

image

How do you delete Apex class from production using VS code?

Visual Studio Code (VS Code) To do the delete we need to do the following steps: Find the class or apex trigger we need to remove and update the metadata status to be “Deleted”. Run the sfdx force deploy command with all of the classes/triggers separated by “,” using the terminal.

Can we delete trigger in production Salesforce?

This is the simplest way to do of all is Deactivate your trigger in your sandbox by unchecking the Active checkbox of the trigger. Create an outbound change set, upload and deploy the change set to production.

Can we edit Apex class in production?

No, it is not possible to edit apex classes and triggers directly in production environment. It needs to be done first in Developer edition or testing org or in Sandbox org. Then, to deploy it in production, a user with Author Apex permission must deploy the triggers and classes using deployment tools.

Which tool can be used to delete an Apex class in production choose two options?

The answer can be to use Notepad text editor and the super lightweight and easy to use Workbench suite. Using these tools, deleting Apex classes and triggers from Salesforce production is a breeze.

How do I delete a production code in Salesforce?

1. Probably the simplest way to delete / disable is to connect to your Salesforce production org from VS Code download the apex class / trigger, change the status of the Apex class / trigger to “Deleted” or “Inactive” in the class/trigger XML file and save. In this step-by-step guide we are going to cover this method.

How do I delete a class in dev console?

Follow the below steps to do that in production instances,Create new project in eclipse and download all the source code from production.Open the meta-data of the file you want to delete in production and change the status to Delete.Click save to server to delete the class in the production.

How do I delete a component from production in Salesforce?

To delete components, perform a deployment with the deploy() call by using a destructive changes manifest file that lists the components to remove from your organization. You can perform a deployment that only deletes components, or a deployment that deletes and adds components.

How do I edit Apex classes in Salesforce?

To access the Apex Classes page, from Setup, enter Apex Classes in the Quick Find box, then select Apex Classes. For additional development functionality, use the Developer Console. To create an Apex class, from the Apex Classes page, click New and write your Apex code in the editor.

Is it possible to change the code directly in production?

You can make certain configuration changes to directly to production but you can not make code changes directly to production.

How do you delete Apex class or trigger in production?

Remove Apex Class or TriggerInstall Ant Migration Tool.Connect to the Production Instance and find the class or trigger that you want to delete.Retrieve the matching class or trigger, and change the Status XML tag from Active to Deleted.Or to disable the trigger change it to Inactive. ... Save the file.More items...

Can you edit an Apex trigger Apex class in production environment?

No, it is not possible to edit apex classes and triggers directly in production environment. It needs to be done first in Developer edition or testing org or in Sandbox org. Then, to deploy it in production, a user with Author Apex permission must deploy the triggers and classes using deployment tools.

How do I know where an Apex class is used?

You can search for the Apex class/page in the IDE, the Search result will show all the matches where the class/page/trigger is referenced. Hope this helps.

The Problem

The most common approach to deleting Apex classes and triggers in a Salesforce production environment is to leverage either the Force.com IDE or the Fo r ce.com Migration tool. These tools have a number of downsides, namely.

The Solution

Let’s say that you have a Salesforce production org that has two Apex classes that need to be deleted.

What is SFDX CLI?

The SFDX CLI is a command-line tool that was first introduced for working with scratch orgs. However, further updates have enabled it to work with sandboxes and production orgs.

Can you reset your Salesforce security token?

Replace <password><security token> with your password and security token, one following the other with no spaces in between. If you do not know your security token, you can reset it from your personal settings in Salesforce.

Force.com Migration Tool (ANT)

The Force.com Migration Tool uses the Apache Ant tool to do deployments (additions, updates, deletes). Additions or updates should be included in the package.xml file and removals need to be done in the destructiveChanges.xml file.

Workbench

If you are infrequently doing deletions or deployments through the Force.com migration tool, Workbench is a better solution. It doesn’t require learning the terminal or learning how to use the ANT. The file structure and files are identical because it is basically running the same process.

Wrapping It Up

In this blog post, we’ve covered how to do deletions of apex classes and apex triggers from a production Salesforce org using Force.com Migration Tool (ANT), Visual Studio Code, Workbench, and even the deprecated Force.com IDE.

image

Why Should I Care?

Deleting Production Code with destructiveChanges.xml

  • The only way to delete classes from a production org is via the metadata API. Fortunately, there are two tools that we can use to easily interface with it. The SFDX CLIis a command-line tool that was first introduced for working with scratch orgs. However, further updates have enabled it to work with sandboxes and production orgs. While documentati...
See more on linkedin.com

Getting Started

  • For the sake of not sending you running around the internet gathering tools, I've compiled a little archive that includes Ant, the Ant Migration Tool, a sample project to remove a file (including destructiveChanges.xml), and scripts to use both Ant or the SFDX CLI. Download the tools here. If you wish to use SFDX, you can download it here. If you would rather use Ant, please make sure t…
See more on linkedin.com

Set Your Credentials

  • Option 1: SFDX CLI
    Inside the folder you extracted, you will find a file called sfdxLogin.bat. For Windwos users, this will execute the SFDX command that authenticates an org on your computer: If you're on any other operating system, you will have to type this in a terminal window (in any folder you'd like). Make …
  • Option 2: Ant Migration Tool
    In the folder you extracted, find the file build.properties. This is where we set our login credentials so that the migration tool removes files from the correctorg, and some poor soul three thousand miles away doesn't wake up to discover theirs completely broken. In the file, find the following s…
See more on linkedin.com

Select Components to Delete

  • Next, find the directory called remove, which contains a file called destructiveChanges.xml. Inside this file you will find this: This tells the system which components you want to delete. In this sample, it will attempt to delete an Apex class called Testing. Makes sense, right? Unless you're one of those people who wins the lottory every week, chances are the class you're trying to delet…
See more on linkedin.com

Final Preperation

  • Before you actually perform the deletion, ask yourself if you're certain this is what you want to do. There is no way to retrieve this data beyond this point. You may want to make a backup, check that nothing else uses the file, consult with others... or maybe you're the type who rolls the dice - well let's roll! Is this a good outcome? What game are we even playing here? Stock photos make …
See more on linkedin.com

Execute The Deletion

  • The last step is to execute the ant migration tool. For Windows users, I've preparedsome batch scripts to handle things depending on your selected method. If you're on a different operating system, you will need to run some commands in the terminal window.
See more on linkedin.com

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9