Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger CreateLead on Contact (after insert) { List<Lead> lstLead = new List<Lead>(); for (Contact con : trigger.new) { lstLead.add(newLead = new Lead ( lead.LeadSource = "Sales Development - Inbound", lead.FfirstName = con.FirstName, lead.LastName = con.LastName, lead.Company = con.Account.Name, lead.Email = con.Email, lead.Phone = con.Account.Phone, lead.Website = con.Account.Website, lead.Status = "Open") ); } if(!lstLead.isEmpty()) { insert lstLead; } }
@isTest public class ConTrigger_Test { static testmethod void testCon(){ Account acc = new Account(Name='Dummy Account',phone='123123123',website='asdasd.com'); insert acc; Contact con = new Contact() ; con.LastName='Test'; con.FirstName='Test'; con.Email='asdasd@sdfsd.com'; con.AccountId =acc.Id ; insert con ; } }