• Aliksandr Vialitski
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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()) {    
    OpportunityReferenceUpdateClass.processOpportunityReferences(Trigger.newMap.keySet());
}

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()) {    
    OpportunityReferenceUpdateClass.processOpportunityReferences(Trigger.newMap.keySet());
}

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?