Gack on batch Apex with Query on IdeaComment, though the SOQL had required filters
Last updated 2022-02-10 ·Reference W-2005266 ·Reported By 0 users
Summary
Summary
===========
-Executing a query on IdeaComment through a batch apex job causes ISE( Internal server error) even if the SOQL passed to the query locator uses appropriate filters.
Implementation restriction. When querying the Idea Comment object, you must filter using the following syntax: CommunityId = [single ID], Id = [single ID], IdeaId = [single ID], Id IN [list of IDs], or IdeaId IN [list of IDs]. “
-Same query works fine via API
Repro
Steps to Replicate
===============
1) create a Batchable apex class implementing the start() method which returns the querylocator for a query on IdeaComment
public class IdeaComment_BatchApex_Issue implements Database.Batchable<sObject>, Database.Stateful
{
Integer batchNumber = 0;
public Database.QueryLocator start(Database.BatchableContext BC)
{
//String query = 'Select Id FROM IdeaComment limit 500'; //API 27 or earlier
String query = 'Select Id FROM IdeaComment WHERE communityId = \'09aD00000000dY3\' limit 500'; //API 28 or later
system.debug(' IdeaComment_BatchApex_Issue > start > query : ' + query );
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext BC, List<sObject> scope)
{
system.debug(' IdeaComment_BatchApex_Issue > execute > batchNumber : ' + (++batchNumber) + ' >> scope : ' + scope);
}
public void finish(Database.BatchableContext BC)
{
system.debug(' IdeaComment_BatchApex_Issue > finish > Database.BatchableContext : ' + BC );
}
}
2) execute the Database.executebatch() with the class created at 1.
Database.executeBatch(new IdeaComment_BatchApex_Issue());
3) You will an exception
Workaround
Workaround
==========
- Change the API ver. of class to 27.0 or earlier. and use the query without communityId filter.
Reported By (0)
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.