You need to sign in to do that
Don't have an account?
m 3
Error: Compile Error: Variable does not exist: Id at line 16 column 38
Hi Please help me above error is throwing when i am trying to save class
public class AddPrimaryContact implements Queueable {
private Contact mainContact;
private list<Schema.Account> accounts;
public AddPrimaryContact (Contact c, String abbr) {
this.mainContact = c;
this.accounts = [Select Id, Name From Account Where BillingState = :abbr limit 200];
}
public void execute (QueueableContext context) {
list<Contact> newContacts = new list<Contact>();
for (Account a :this.accounts) {
Contact newContact = this.mainContact.Clone();
newContact.AccountId = a.Id;
newContacts.Add(newContact);
}
insert newContacts;
}
}
public class AddPrimaryContact implements Queueable {
private Contact mainContact;
private list<Schema.Account> accounts;
public AddPrimaryContact (Contact c, String abbr) {
this.mainContact = c;
this.accounts = [Select Id, Name From Account Where BillingState = :abbr limit 200];
}
public void execute (QueueableContext context) {
list<Contact> newContacts = new list<Contact>();
for (Account a :this.accounts) {
Contact newContact = this.mainContact.Clone();
newContact.AccountId = a.Id;
newContacts.Add(newContact);
}
insert newContacts;
}
}
There is no issue in your code please try again with same code.It will work.
Thanks
Sanjay Bhati