
How do I delete triggers from salesforce
- Assuming you have a sandbox environment synchronized with your Prod org, you will first want to inactivate the...
- In the Sandbox org, you will then want to run all tests: Navigate to Setup->Develop->Apex Classes and click "Run All...
- Once all tests are passing, you can now deploy these changes to your production...
- Install 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.
How do I delete a trigger in Salesforce?
Click on an object for example Employee object. Then scroll down and you will see a section triggers where you will find list of triggers created for that object. Select the trigger which you do not need and delete.
How to retrieve the metadata of a trigger in Salesforce?
Unzip the retrieved metadata folder. In the triggername.trigger-meta.xml file change the status from Active to Inactive. Now zip the folder back and deploy it using Workbench. d) Via Salesforce CLI Create a package.xml file to retrieve the metadata of the trigger.
How to deploy destructive changes to Salesforce?
More information on destructive changes can be found here. Now there are two files in your folder. Open the folder, select both the XML files, right-click and select ‘Send To > Compressed Folder’. Keeping the default name of ‘package’ for the folder is fine. You are now setup to deploy the destructiveChanges.xml file to Salesforce.
How to delete a trigger from the production environment?
6) Right click on the specified trigger and select delete. Accept the option to delete from server. Since the trigger is inactive - it can now be deleted from the production environment. You can use a similar approach with the Ant Migration toolkit.

Can we delete a trigger?
Permissions. To delete a DML trigger requires ALTER permission on the table or view on which the trigger is defined. To disable or enable a DML trigger, at a minimum, a user must have ALTER permission on the table or view on which the trigger was created.
Can we edit triggers 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.
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.
Can we delete class from production Salesforce?
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.
How do you delete Apex class or trigger from 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 I deactivate trigger in Salesforce?
You can Inactive the trigger using following steps: Login to the sandbox. Go to the Trigger and Click on Edit and Uncheck the IsActive box (see the screenshot), and Click on Save. Create a Change Set and include the Trigger in the changeset and deploy the same into the Production.
How do I disable a trigger in Test class in Salesforce?
If you want to default the trigger to off, have your handler set bypassTrigger = Test. isRunningTest() . That way, you can still toggle it on/off when you run certain tests in your suite.
Does After trigger work on Delete in Salesforce?
Trigger After Delete Salesforce executes the custom logic after the data is deleted from the Salesforce Database. If you are looking to delete related records, you can make use of Trigger After Delete Salesforce.
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.
What is the difference between trigger and a workflow?
Trigger works before and after some actions,Coding is required. Workflows work only after some actions, Coding is not required. Workflow is automated process that fired an action based on Evaluation criteria and rule criteria.
How do I disable managed package triggers in Salesforce?
We can't deactivate managed package triggers. Check hierarchical custom setting in a managed package if there is a way to enable/disable any functionality. Licensing can unlock custom settings.
Can you edit a Visualforce page in production environment?
Yes, you can edit a Visualforce page in production.
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.

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 documentation can be a little unclear on some …
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…
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…
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…
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 …
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.