You need to sign in to do that
Don't have an account?
Jayesh Deo 2
Method does not exist or incorrect signature: void add(List<Case>) from the type Case
I am getting mentioned error while adding related 10 case records to account record. Please help.
account acc=new account();
acc.name='cognizant';
insert acc;
ID accID=acc.ID;
list <contact> con=new list <contact>();
for(integer counter=1;counter<=5; counter++)
{
contact cont= new contact();
cont.lastname='plumber'+counter;
cont.email='bulky'+counter+'@gmail.com';
cont.AccountId=accID;
con.add(cont);
}
insert con;
list <case> caselist=new list <case> ();
for(integer counter=1; counter<=10; counter++)
{
case cd=new case();
cd.status='working';
cd.SuppliedPhone='counter'+counter;
cd.AccountId=accID;
cd.add(caselist);
}
insert caselist;
account acc=new account();
acc.name='cognizant';
insert acc;
ID accID=acc.ID;
list <contact> con=new list <contact>();
for(integer counter=1;counter<=5; counter++)
{
contact cont= new contact();
cont.lastname='plumber'+counter;
cont.email='bulky'+counter+'@gmail.com';
cont.AccountId=accID;
con.add(cont);
}
insert con;
list <case> caselist=new list <case> ();
for(integer counter=1; counter<=10; counter++)
{
case cd=new case();
cd.status='working';
cd.SuppliedPhone='counter'+counter;
cd.AccountId=accID;
cd.add(caselist);
}
insert caselist;
The main issue in the code is you have to add the case into the caselist but you have done the other way.
I have corrected it in the below . The error is highlited.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,