You need to sign in to do that
Don't have an account?
sfdc guru 17
test class !!!
Hi All
How to write test class for the my method
How to write test class for the my method
public static void updating(List<Contact> triggerNew,Map<Id,Contact> triggerOldMap){ try{ List<String> addressIds = new List<String>(); for(Contact cont : triggerNew){ if(cont.location__c != null && cont.location__c !=triggerOldMap.get(cont.Id).location__c ){ addressIds.add(cont.location__c); } } Map<Id,custom__c> add = new Map<Id,custom__c>([Select Id,,name,field1__C,field2__C,field3__C from custom__c where id IN: addressIds]); for(Contact cont : triggerNew){ if(cont.location__c != null && cont.location__c !=triggerOldMap.get(cont.Id).location__c ){ if(add.get(cont.location__c) != null){ cont.field1__C = add.get(cont.location__c).Name; cont.field2__C = add.get(cont.location__c).field2__C; cont.field3__C = add.get(cont.location__c).field3__C; } } } }catch(DmlException e) { Logger.error('DMLException : '+e.getMessage(), null, 'updating'); }catch(Exception ex) { Logger.error('DMLException : '+ex.getMessage(), null, 'updating'); } }
Try this
if you are getting any error plz let me knw.
Thank you