I'm Trying to deactivate users belongs to account/contacts which related to Termination_request__c object. based on one approval process the status__c field in Termination_request__c record will update. Whenever status field updated, the Termination request trigger should fire. But not firing. What could be the problem.

Here is my trigger which should fire:

trigger TerminationRequestTrigger on Termination_Request__c (before update, after update) {
    Trigger_Controls__c CS = Trigger_Controls__c.getOrgDefaults();
     if(CS.Termination_Request_Trigger__c){// trigger toggle
        TerminationRequestTriggerHandler handler = new TerminationRequestTriggerHandler (Trigger.isExecuting, Trigger.size);
        //Runs on before update only
        if(Trigger.isBefore && Trigger.isUpdate) {    
        }//end of before update only
        //Runs on after update only
        else if(Trigger.isAfter && Trigger.isUpdate) {   
            handler.OnAfterUpdate(trigger.new, trigger.newMap, trigger.oldMap);
        }//end of after update condition
    }// end of trigger toggle

Looking at your trigger Code one thing to note is there is custom setting named Trigger Controls which has a field named "Termination_Request_Trigger__c".Check if this value is checked.

Also best way to debug apex triggers is to use developer console and use system.debug at appropriate points to check flow of your trigger.

  • The field is unchecked. Should it be checked to fire trigger or can we make fire trigger with unchecked? – don don2 Nov 27 '15 at 6:42
  • What is the use of Trigger_Controls__c.getOrgDefaults() – don don2 Nov 27 '15 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.