You need to sign in to do that
Don't have an account?
SFDC Coder 8
Test class for Task Trigger updating contact
Hi All,
I am new to Salesforce.
I have written a trigger on task to update contact record.
I want to write test class for the same. Here is my code.
Please help me to write test class for the above code.
Thanks in Advance
I am new to Salesforce.
I have written a trigger on task to update contact record.
I want to write test class for the same. Here is my code.
trigger TaskUpdate on Task (after update) { List<Id> Ids=new List<Id>(); for(Task t:trigger.new) { if(String.valueOf(t.whatId).startsWith('001')==TRUE) { Ids.add(t.whatId); } } Map<Id,contact> con = new Map<Id,contact>([SELECT Id, P1__c,p2__c,P3__c,AccountId FROM contact WHERE Contact.AccountId IN:Ids]); For(Task t2 : trigger.new) { if(con.get(t2.whoid) != null) { con.get(t2.whoid).P1__c = t2.P1__c ; con.get(t2.whoid).p2__c = t2.p2__c ; con.get(t2.whoid).P3__c = t2.P3__c ; con.get(t2.whoid).P4__c= t2.P4__c; con.get(t2.whoid).P5__c= t2.P5__c; con.get(t2.whoid).P6__c= t2.P6__c; con.get(t2.whoid).P7__c= t2.P7__c; con.get(t2.whoid).P8__c__c= t2.P8__c; } } update con.values(); }
Please help me to write test class for the above code.
Thanks in Advance
Let us know if this will help you