public class relatedLeadshelper { public void createLeadrecord() { Lead ld = new Lead (); ld.FirstName='Test'; ld.LastName='Lead record'; ld.Company='Microsoft corp'; ld.Status='Open not connected'; ld.Industry='Banking'; ld.AnnualRevenue=45000000; ld.Phone='990887766'; ld.Fax='8899776655'; ld.Email='sample@gmail.com'; ld.LeadSource='Web'; ld.Website='www.salesforce.com'; ld.city='Hyderabad'; ld.State='Telangana'; ld.country='India'; insert ld; //create contact record if(ld.id!=null) system.debug('Lead record is created with id ..:'+ld.id); contact con = New Contact(); con.FirstName='NAYANATHARA'; con.LastName='Contact record'; con.Title='Sales manager'; con.Phone='7780282373'; con.Email='Sample@gmail.com'; con.HomePhone='99005544433'; con.MailingCity='Hyderabad'; con.MailingState='Telangana'; con.MailingCountry='India'; con.Leadid=ld.id; insert con; if(con.id!=null) system.debug('contact record is created with id ..:'+con.id); } } Error:Variable does not exist: Leadidwhats wrong on my code