function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
John AthitakisJohn Athitakis 

isBatch() firing when called from Queueable?

Short story. I have a trigger on a custom object that invokes a queueable class. That class is gathering up related opportunities (via a lookup) and editing them. 

On the opportunity level, I have a bit of future code that fires. 

Now before my future code is invoked I have the following.

if(!System.isFuture()) {    

To solve an issue where I was having a nightly batch executing that was causing an error (batch invoking future is a no no) I changed it to this.

if(!System.isFuture() && !System.isBatch()) {    

Success---no more errors...however for some reason now that I added isBatch to my conditions to ensure its not firing due to my nightly Batch, it seems my Queueable code is now no longer able to update it? It doesn't make a whole lot of sense to me.


Here is a glimpse of my apex jobs (there are no batches running)

Without isBatch, the Queueable code is completing and kicking off my future code. 

4/11/2016 3:22 PMFutureCompleted 000Athitakis, John4/11/2016 3:22 PMOpportunityReferenceUpdateClassprocessOpportunityReferences7071100000s5byt000000000000000  
 4/11/2016 3:22 PMQueueableCompleted 000Athitakis, John SalesAreaRelatedOpportunityUpdateClass 7071100000s5bta000000000000000 

With isBatch, the Future code is never fired. 

4/11/2016 3:26 PM	Queueable	Completed	 	0	0	0	Athitakis, John	 	SalesAreaRelatedOpportunityUpdateClass	 	7071100000s5c5F	000000000000000

My confusion is, I would expect this behavior if I was using isQueueable, but I'm not? (One more, there are no batches going on from what I can see).


Any ideas? 

John AthitakisJohn Athitakis
Any suggestions here? To review, the isBatch logic is preventing my code from executing even though what is invoking it is Queueable. 
John AthitakisJohn Athitakis
No suggestions or questions? Have not found any resources to help on this. 
Aliksandr VialitskiAliksandr Vialitski
Documenation (
Returns true if a batch Apex job invoked the executing code, or false if not. In API version 35.0 and earlier, also returns true if a queueable Apex job invoked the code.