Updating large numbers of records

PHOTO EMBED

Fri Oct 06 2023 22:09:54 GMT+0000 (Coordinated Universal Time)

Saved by @gbritgs #apex

for(List<Lead>) leads : [SELECT Id, LastName FROM Lead] {
    List<Lead> toUpdate = new List<Lead>();
    for(Lead nextLead : leads) {
        nextLead.LastName = 'Test';
        toUpdate.add(nextLead);
    }

    update toUpdate;
}
content_copyCOPY