Bulk Upsert and Update of CaseComments don't work correctly
Apex , Performance , Platform , Developer Console
Last updated 2022-02-15 ·Reference W-4236035 ·Reported By 25 users
In Review
Summary
Upserting and Updating the CaseComment object methods gives error: QUERY_TIMEOUT, Your query request was running for too long.
This happens for Lists of CaseComments upserting or updating in bulk.
This occurs in test methods and outside test methods
System.DmlException: Update failed. First exception on row 1 with id 00axx000000BbSoAAK; first error: REQUEST_RUNNING_TOO_LONG, Your request was running for too long, and has been stopped.: []
The error also occurs with upsert command and the error QUERY_TIMEOUT will occur for same code in test methods
Repro
Open the developer console and paste the following code in anonymous debug window and run
Account newaccount = New Account(Name='test account');
Insert newaccount;
Case newcase = New Case(AccountId=newaccount.Id, SuppliedEmail='test@tesc.com');
Insert newcase;
List<CaseComment> testcomments = New List<CaseComment>();
for(Integer i=0; i<2; i++){
CaseComment test = New CaseComment(ParentId=newcase.Id, CommentBody='test comment' + String.valueOf(i));
testcomments.add(test);
}
Insert testcomments;
List<CaseComment> comments = [SELECT ParentId, CommentBody FROM CaseComment WHERE ParentId=:newcase.Id];
for(CaseComment comm : comments){
comm.CommentBody += '!';
}
Update comments;
Workaround
Do not update/upsert CaseComments in bulk.
Instead, only update/upsert one at a time.
Reported By (25)











Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.