[SalesForce] Activate an InActive Trigger using the Force.com IDE

Trigger code :

trigger SetFieldsOnContact on Contact(before insert){
    System.debug('------------inside contact trigger SetFieldsOnContact before insert---------');
    String accId = [SELECT Id from Account WHERE Name='GenePoint'].Id;
        for(Contact c : Trigger.new){
        c.Description='This contact updated.';
        c.Title='Mr.';
        c.Phone='8888888888';
        c.Email='abc.def@gmail.com';            
        if(c.AccountId == null){
        c.AccountId = accId;
        }
        }
}

Execute Anonymous code :

List<Contact> contList = new List<Contact>();
for(Integer j=0;j<200;j++){
Contact c = new Contact();
c.FirstName = 'Trigger Contact'+j;
c.LastName = 'Trigger Contact'+j;
contList.add(c);
}
insert contList;

Issue : Fields on inserted contacts are not getting updated.

Best Answer

The trigger will need to be activated in order to run. You can do this from Developer -> Apex Triggers -> Edit next the name of your trigger. There is a checkbox called "isActive". Assure that this is checked.

You can also edit it with the Force.com IDE by modifying the metadata file for the given trigger. Change status from "InActive" to "Active".

<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://xxxxxxxxxxxxx">
    <apiVersion>32.0</apiVersion>
    <status>Active</status>
</ApexTrigger>
Related Topic