You need to sign in to do that
Don't have an account?
Abid ullah
Update failed. MISSING_ARGUMENT, Id not specified in an update call:
public class AddPrimaryContact implements Queueable {
private Contact comingContact;
private string state;
public AddPrimaryContact(Contact record, string stateabbrivation){
this.comingContact = record;
this.state = stateabbrivation;
}
public void execute(QueueableContext qcon){
List<Account> allAccounts = [SELECT id,Name,(SELECT FirstName,LastName,Id from contacts) from Account
where BillingState=:this.state limit 200];
List<Contact> contactToUpdate = new List<Contact>();
for(Account acc:allAccounts){
Contact c = this.comingContact.clone();
c.AccountId = acc.Id;
contactToUpdate.add(c);
}
if(contactToUpdate.size()>0){
system.debug(contactToUpdate);
update contactToUpdate;
}
}
}
and in the execute window:
Contact aContact = [select id,FirstName,LastName from Contact where Id=:'0035f000009OGaqAAG'];
AddPrimaryContact checking = new AddPrimaryContact(aContact,'NY');
system.enqueueJob(checking);
and give error.
private Contact comingContact;
private string state;
public AddPrimaryContact(Contact record, string stateabbrivation){
this.comingContact = record;
this.state = stateabbrivation;
}
public void execute(QueueableContext qcon){
List<Account> allAccounts = [SELECT id,Name,(SELECT FirstName,LastName,Id from contacts) from Account
where BillingState=:this.state limit 200];
List<Contact> contactToUpdate = new List<Contact>();
for(Account acc:allAccounts){
Contact c = this.comingContact.clone();
c.AccountId = acc.Id;
contactToUpdate.add(c);
}
if(contactToUpdate.size()>0){
system.debug(contactToUpdate);
update contactToUpdate;
}
}
}
and in the execute window:
Contact aContact = [select id,FirstName,LastName from Contact where Id=:'0035f000009OGaqAAG'];
AddPrimaryContact checking = new AddPrimaryContact(aContact,'NY');
system.enqueueJob(checking);
and give error.
Can you add a system.debug statement for the contactToUpdate and for c.AccountId and see what is returned
Similar post https://salesforce.stackexchange.com/questions/141288/error-when-update-missing-argument-id-not-specified-in-an-update-call
Thanks