Hi I am try to deactivate trigger in production through change sets.

First i deactivate trigger in sandbox and try to deploy that trigger to production.But i face some issues like.

But test class of that trigger raise a issue like.Even I put assertion statement in comments.

System.AssertException: Assertion Failed: Expected: 35, Actual: null Stack Trace: Class.TestDeviceUpdate.testStandardUseropp: line 45, column 1

Any help is appreciated.

My Apex trigger

trigger DeviceUpdate on BI_Device__c (before insert,before update) 

if(Trigger.isBefore && trigger.isInsert || Trigger.isBefore && trigger.isUpdate ) 


Apex Class

public class DeviceMapping 
  public Static void deviceUpdate (List<BI_Device__c> Deviceids)
       List<String> s= new List<String> ();
       for(BI_Device__c b:deviceids) 

       List<Account> contactListToDelete = [select id,No_of_Devices_activated_in_Portal__c,Azuga_Customer_ID__c from account where Azuga_Customer_ID__c IN : s];
       for(Account a:contactListToDelete) 
           for(BI_Device__c bi: deviceids)
              Upsert a;

         /*List<Account> contactListToDelete = [select id from account where Azuga_Customer_ID__c IN : Deviceids];      
         Map<Id, account> opMap = new Map<Id, account>();
         for(account o : contactListToDelete) 
        } */
         //Delete if list is not empty



My test class

 public class TestDeviceUpdate 

     static testMethod void testStandardUseropp() 
         // Create a new user with the Standard User profile
         Profile standardProf = [select id from profile where name='Standard User']; 
         User su = new User(alias = 'standt', email='[email protected]', 
         emailencodingkey='UTF-8',FirstName='opp', lastname='testing', languagelocalekey='en_US', 
         localesidkey='en_US', profileid = standardProf.Id, 
         timezonesidkey='America/Los_Angeles', username='[email protected]');

          // Switch current user to Standard User

          List<Account> Accounts = new List<Account>{};

          for(Integer i = 0; i < 50; i++) 

          Account a = new Account(Name='Test'+ i,Azuga_Customer_ID__c='123'+i);
               insert Accounts;
               List<BI_Device__c> Bidevices = new List<BI_Device__c>{};

          for(Integer i = 0; i < 50; i++) 

            BI_Device__c b = new BI_Device__c(Name='Test'+ i,Azuga_Customer_ID__c='123'+i,

            // Insert the Account records that cause the trigger to execute.
                insert Bidevices;
            // Stop the test, this changes limit context back to test from trigger.

            // Query the database for the newly inserted records.
            List<Account> insertedAccounts = [SELECT Name,No_of_Devices_activated_in_Portal__c,
                                  Azuga_Customer_ID__c FROM Account
                                  WHERE Id IN :Accounts];

            // Assert that the Description fields contains the proper value now.
            /*for(Account l : insertedAccounts)

  • 3
    I am pretty sure that there are some logic, that trigger is doing, and thats why tests are failing. Try to fix your tests in sandbox and deploy to production together with trigger
    – kurunve
    Commented Apr 18, 2016 at 11:54
  • When i run test class in sandbox.Everything is fine@kurunve
    – Pavan tej
    Commented Apr 18, 2016 at 12:22
  • And Even trigger is also Working fine in production.But I want to deactivate it for temporary..
    – Pavan tej
    Commented Apr 18, 2016 at 12:34
  • 2
    Are you deploying the updated test class in the same changeset? Commented Apr 18, 2016 at 13:02

2 Answers 2


The best way is to do it with Eclipse. Select the XML file of that trigger in eclipse and change the "status" to "inactive", after that, upload the trigger back to production.

  • thanks buddy i had some doubt.I setup eclipse and connected to my sandbox.I change the status to inactive in xml. Now how to deploy to production and i have to deploy both trigger and class,Test class,XML file also.@Viasur
    – Pavan tej
    Commented Apr 20, 2016 at 15:59
  • Just make sure you are using the "Work Online" mode in Eclipse. That is how I normally work. This way all changes are saved to your sandbox after you saved them on Eclipse. If you have updated the XML file and you are using work online mode, the changes will be now on the sandbox. All you need to do is to create a change set with the trigger and the corresponding test class for that trigger. Send it to production and it will be inactive. To check if you are working online mode right click on your SFDC project folder in Eclipse, after that click on Force.com-> Work Online. Hope it helps. Commented Apr 20, 2016 at 17:33

There are a number of ways to stop a trigger to run.

  • Deactivate trigger through change sets
  • Comment Code
  • Use custom settings
  • Using Eclipse IDE
  • Using ANT tool

I've consolidated the list. More on this here https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .