You need to sign in to do that
Don't have an account?
Ramana123
what to write in anonymous block for this code to execute..? i am not getting please helpm me in this
code
public class AddPrimaryContact implements Queueable {
private Contact s;
private String State;
public AddPrimaryContact(Contact s, String State) {
this.s = s;
this.state = State;
}
public void execute(QueueableContext context) {
List<Account> ListAccount = [SELECT ID, Name ,(Select id,FirstName,LastName from contacts ) FROM ACCOUNT WHERE BillingState = :state LIMIT 200];
List<contact> con = new List<Contact>();
for(Account acc: ListAccount)
{
Contact cont = s.clone(false,false,false,false);
cont.AccountId = acc.id;
con.add( cont );
}
insert con;
}
}
what to wrire here in anonymous block ..?
AddPrimaryContact obi = new AddPrimaryContact(s,usa);
Database.executeBatch(obj);
public class AddPrimaryContact implements Queueable {
private Contact s;
private String State;
public AddPrimaryContact(Contact s, String State) {
this.s = s;
this.state = State;
}
public void execute(QueueableContext context) {
List<Account> ListAccount = [SELECT ID, Name ,(Select id,FirstName,LastName from contacts ) FROM ACCOUNT WHERE BillingState = :state LIMIT 200];
List<contact> con = new List<Contact>();
for(Account acc: ListAccount)
{
Contact cont = s.clone(false,false,false,false);
cont.AccountId = acc.id;
con.add( cont );
}
insert con;
}
}
what to wrire here in anonymous block ..?
AddPrimaryContact obi = new AddPrimaryContact(s,usa);
Database.executeBatch(obj);
System.enqueueJob(new AddPrimaryContact(s,usa));
if it helps please mark as correct, it may help others
System.enqueueJob(new AddPrimaryContact(new Contact(LastName='test'),'usa'));
if it helps please like or mark as correct, it may help others