You need to sign in to do that
Don't have an account?
rornelas
Handler Class for my trigger behaving very weird
Experiencing some very odd behavior with my Trigger my Class curly braches are in red even though my class compiles. Now my trigger appears not be working. My // On After Update Trigger method worked, but now it doesn't. One thing I noticed is that when I added //OnBeforeInsert
public class contact_trigger_handler { public static Boolean isFirstTime = True; public Contact_trigger_handler() { } // On Before Insert // http://salesforce.stackexchange.com/questions/63314/insert-trigger-on-accountusing-map public void OnBeforeInsert(List<Contact> con_amt) { Double Total_Amount = 0; for( Contact c1: [Select Amount__c from Contact Where CreatedDate=TODAY AND CreatedbyID = :UserInfo.getUserId() ] ) { Total_Amount = Total_Amount + c1.Amount__c; } for(Contact c2 : con_amt) { Total_Amount = Total_Amount + c2.Amount__c; if(Total_Amount > 100000) { c2.addError('You have exceeded your daily limit'); } } // Here taking the Set because we dont need to maintain duplicate Set<Id> accIdSet = new Set<Id>(); for( Contact con : con_amt ) { if(con.AccountId != null) { accIdSet.add(con.AccountId); } } List<Account> accList = [Select Id, Name, Type from Account where Id IN :accIdSet ]; if(!accIdSet.isEmpty()) { for(Contact con : con_amt ) { if(con.AccountId != null) { for(Account acc: accList) { if(con.AccountId == acc.Id) { con.Acc_Type__c = acc.Type; } } } } } } // On After Insert public void OnAfterInsert(List<Contact> newRecords) { } // On Before Update public void OnBeforeUpdate(List<Contact> oldRecords, List<Contact> newRecords, Map<Id, Contact> newRecordsMap) { } // On After Update public void onAfterUpdateEvent(List<Contact> con_List) { List<Contact> con_to_be_update = new List<Contact>(); system.debug('Trigger new Size ' +con_list.size()); for(Contact con :con_List) { system.debug('Trigger Updating Properly .... ' + con.Languages__c); con_to_be_update.add(new Contact(Id=con.Id, Second_Language__c = con.Languages__c)); } if(con_to_be_update.size() > 0){ update con_to_be_update; } } // On Before Delete // http://developer.force.com/cookbook/recipe/comparing-queries-against-trigger-old-and-trigger-new public void OnBeforeDelete(List<Contact> deletedRecords, Map<Id, Contact> deletedRecordsMap) { /*for (Job_Applications__c jobApp : [SELECT Id FROM Job_Applications__c WHERE Candidate__c IN :Trigger.oldMap.keySet()]) { Trigger.oldMap.get(jobApp.Candidate__c).addError( 'Cannot delete candidate with a job application'); }*/ /* for(Contact co : Trigger.Old){ Job_Applications__c chlist = [select id, Candidate__c from Job_Applications__c where Candidate__c =: co.id]; //list to hold child matches the parent if(chlist.size() > 0){ co.adderror('Child record is refering this record...So, you cannot delete it...!'); } }*/ } // On After Delete public void OnAfterDelete(List<Contact> deletedRecords, Map<Id, Contact> deletedRecordsMap) { } // On Undelete public void OnUnDelete(List<Contact> undeletedRecords) { } }
2. Whats the observation in debug logs ?
3. try reopening the developer console to identify the red color for the braces , if it still persists.
https://www.dropbox.com/s/9frbm0hgaxuqqma/apex-07L3600000FWecQEAT.log?dl=0
I've tried opening via setup menu and Sublime Mavensmate and no go.