5

To go with the new System.Queueable interface, I'm looking for the analogy of:

  • System.isBatch()
  • System.isFuture()
  • System.isScheduled()

Is there a System.isQueued() or something?

9

Spring '16 brings us a new method:

System.isQueueable() which takes care of this requirement.

releasenotes.salesforce.com/en-us/spring16/release-notes/rn_apex_new_classes_methods.htm

As of Spring '16, isBatch() does NOT return true from inside Queueable implementation.


  • 1
    How did you get round the 'Method is not implemented.' Error? Sandbox? – TimChadwick Dec 4 '14 at 8:40
  • @TimChadwick raise a case to Salesforce and ask them to turn the good stuff on. – bigassforce Dec 4 '14 at 8:45
  • Haha right'O ta – TimChadwick Dec 4 '14 at 8:46
  • But how do you distinguish between being in a batch job and a queued job? :) – kbentsen Jun 22 '15 at 23:21
  • @kbentsen if (context instanceof QueueableContext) ... – bigassforce Jun 23 '15 at 9:24
0

I think that better is option is use this query, to veryfy if your class is in the queue

SELECT Id, ApexClassId from AsyncApexJob WHERE JobType = 'Queueable' AND Status = 'Queued' AND ApexClassId in (SELECT Id FROM ApexClass WHERE NAME = 'Imp')

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.