You need to sign in to do that
Don't have an account?
Nadia Gainsbourg
Test class for a basic Task trigger
Hello! I have a basic Task trigger that I need to move to production; however, I have no idea how to write a test class for it (don't understand test classes at all). Would appreciate any help on this!
trigger TaskTrigger on Task (before insert) {
if ((Trigger.isBefore && Trigger.isInsert)) {
for(Task t : Trigger.new) {
if(String.isNotBlank(string.valueOf(t.WhoId)) && (String.valueOf(t.WhoId)).startsWith('003') ){
// contact
t.Contact_Phone_Hidden_Lookup__c = t.WhoId;
}
else if(String.isNotBlank(string.valueOf(t.WhoId)) && String.valueOf(t.WhoId).startsWith('00Q') ){
t.Lead_Phone_Hidden_Lookup__c= t.WhoId;
}
}
}
}
trigger TaskTrigger on Task (before insert) {
if ((Trigger.isBefore && Trigger.isInsert)) {
for(Task t : Trigger.new) {
if(String.isNotBlank(string.valueOf(t.WhoId)) && (String.valueOf(t.WhoId)).startsWith('003') ){
// contact
t.Contact_Phone_Hidden_Lookup__c = t.WhoId;
}
else if(String.isNotBlank(string.valueOf(t.WhoId)) && String.valueOf(t.WhoId).startsWith('00Q') ){
t.Lead_Phone_Hidden_Lookup__c= t.WhoId;
}
}
}
}
Raj Vakati