You need to sign in to do that
Don't have an account?
sachitanand kumar
How to write test class for this lead trigger
Hello everyone, plz tell me how to write the test class for this trigger listed below.
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>();
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.channel__c);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.channel__c= leadStatus.get(c.Id);
}
update conContacts;
}
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>();
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.channel__c);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.channel__c= leadStatus.get(c.Id);
}
update conContacts;
}
use below code
Hope this will help you,
Thanks
karthik