Hey Prashanth, There is no field "conid" exist on case object. "ContactId" is the correct field as it is the lookup field with contact object. so your code will be like below
Kindly mark it as best answer.public class contactsrecordshelper
{
public static void createaccountrecord()
{
contact con = new contact();
con.firstname='Latest';
con.LastName='Bheemla';
con.Email='latestbheemla@gmail.com';
con.MailingCity='Hyderabad';
con.MailingState='Telangana';
con.MailingCountry='India';
insert con;
//created related case record
if(con.id!=null)
{
system.debug('contact record created with id..:'+con.id);
case cs = new case();
cs.status = 'New';
cs.Priority='High';
cs.Type='Mechanical';
cs.Reason='Performance';
cs.contactId=con.id;
insert cs;
if(cs.id!=null)
system.debug('case record is created with id..:'+cs.id);
}
}
}
Thanks
1 risposta