You need to sign in to do that
Don't have an account?
please explain the below code
public class UpdateParentAccount implements Queueable {
private List<Account> accounts;
private ID parent;
public UpdateParentAccount(List<Account> records, ID id) {
this.accounts = records; this.parent = id;
}
public void execute(QueueableContext context) {
for (Account account : accounts)
{
account.parentId = parent;
// perform other processing or callout
}
update accounts;
}
}
It's a queueable class and in the constructor you see two parameters which is List<Account> records -> Account records and Id id -> ParentId . And in execute method account records ParentId field is set with the ParentId which is being sent from some other class in the form of System.enqueueJob(new UpdateParentAccount (records, '001xxxxxxxx')) and then those records are updated via performing a DML operation.
If you want to perform callout make sure you implement Database.callouts interface.
Hope it clears.
Thanks
All Answers
It's a queueable class and in the constructor you see two parameters which is List<Account> records -> Account records and Id id -> ParentId . And in execute method account records ParentId field is set with the ParentId which is being sent from some other class in the form of System.enqueueJob(new UpdateParentAccount (records, '001xxxxxxxx')) and then those records are updated via performing a DML operation.
If you want to perform callout make sure you implement Database.callouts interface.
Hope it clears.
Thanks
It's a queueable class and in the constructor you see two parameters which is List<Account> records and one id of the parent record to be updated .. I you execut the below code from developer console you can able to see the all list of accounts are updated with parent account