Trigger and test class works in Sandbox with 100% code coverage (trigger code listed below)
I have checked the following: 1.My code coverage in Production is 98% and Sandbox is 94% according to Salesforce's "Developer Console" 2. I have turned off all Validation and Workflow rule in production to make sure it's not an issue with these rules before deployment (same result of 38% overall coverage)
I have reached with the conclusion that my trigger below is somehow breaking Apex Test Classes that are in place when I try to deploy, because along with the "38%" error message, it tells me that there are 5 other triggers (that are successfully deployed previously in production and is in production with 100% coverage) with 0% test coverage during deployment.
Please see my trigger below and please help, thanks! (P.S. This trigger had worked before but I added MAP near the bottom of this new trigger hoping that this would resolve any issues when our users use CRM tools like Dataloader to mass update/insert old/new Contact records).
trigger primaryLiaisonCount2 on Contact(after update) {
if (checkRecursive.runOnce()) {
List < Account > accList = new List < account > ();
List < Account > accListToUpdate = new List < account > ();
Set < Account > accSet = new Set < Account > ();
set < String > allAccIds = new Set < String > ();
for (Contact c1: trigger.new) {
if (c1.Contact_ID_18_Characters__c != null) {
allAccIds.add(c1.AccountID);
}
}
decimal amount1 = [SELECT count() FROM Contact WHERE AccountID IN: allAccIds AND Primary_Liaison__c != null AND Marketing_Status__c != 'Gone From Company'
LIMIT 25
];
LIST < Account > acc1 = [SELECT ID FROM Account WHERE ID IN: allAccIds AND recordtypeID = '012000000000j8S'
LIMIT 25
];
MAP < String, Account > firstMap = new MAP < String, Account > ();
for (Account acc2: acc1) {
firstMap.put(acc2.id, acc2);
}
for (Contact c1: trigger.new) {
Account acc3 = firstMap.get(c1.accountId);
acc3.Primary_Liaisons__c = amount1;
accList.add(acc3);
}
accSet.addall(accList);
accListToUpdate.addall(accSet);
Update accListToUpdate;
}
}