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
gidiemgidiem 

Rename trigger in production

When we pushed a trigger to production it didn't have the naming convention we desired. Is it possible to change the name? I found this article but it doesn't inspire enough confidence to deploy a second trigger to production in case I make the situation worse having 2 triggers. I followed every step but I don't want to push it in case they are wrong. In addition, I do understand triggers can be deactivated and deleted but I do not want to go that route due to time restrictions. Thanks in advance.

Article: https://salesforce.stackexchange.com/questions/21219/how-to-rename-a-trigger
Best Answer chosen by gidiem
Glyn Anderson 3Glyn Anderson 3
Sorry, the only way to get a trigger with the correct name is to deploy it again with the correct name.  This will leave the wrong-named trigger in the org.  When you deploy the new trigger, you can simultaneously make the old trigger inactive.  So it's dead code, but does no harm.  A destructive deployment can be used later to delete the trigger.

All Answers

Glyn Anderson 3Glyn Anderson 3
Sorry, the only way to get a trigger with the correct name is to deploy it again with the correct name.  This will leave the wrong-named trigger in the org.  When you deploy the new trigger, you can simultaneously make the old trigger inactive.  So it's dead code, but does no harm.  A destructive deployment can be used later to delete the trigger.
This was selected as the best answer
jigarshahjigarshah
You can follow the steps outlined below to address your issue.
  1. Comment out the code within the existing trigger on the sandbox and deploy the same code to your Salesforce production instance. This will deactivate the existing code and render the old trigger as inactive.
  2. Copy paste the same code from the Sandbox to create a new Apex Trigger with the expected naming convention.
  3. Deploy the newly created Apex trigger in step # 2 which contains the expected business logic.
  4. You can then use the Force.com IDE or a destructive changes using ANT to delete the old trigger code from step # 1
This way you mitigate the risk of having 2 Apex triggers existing which could possibly produce unexpected results as well as having unwanted obsolete code doing nothing. Unfortunately this is the only way to overcome the outlined issue.

Please DO NOT forget to mark this thread as SOLVED if this answer helps reoslve your issue.