I am getting an error in the for loop.
Error: Variable does not exist: acclist
public class AddPrimaryContact implements Queueable {
Private Contact conl = new Contact();
Private String sty;
Public List<Contact> coninsert = new List<Contact>();
public AddPrimaryContact(Contact conlist, String str)
{
this.conl = conlist;
this.sty= str;
}
public void execute(QueueableContext context)
{
for(List<Account> acclist: [Select id,name from Account where BillingState =:sty]);
{
for(Account accops:acclist)// Error in this statement
{
conl.lastname = 'testLast';
conl.accountid = accops.id;
coninsert.add(conl);
}
}
if(coninsert.size()>0)
{
insert coninsert;
}
}}