4

I have a apex class which implements Schedulable interface, I want to find out whether this class is already scheduled or not? Please help me with SOQL query to find out this.

4

To find out if a given class is scheduled use an SOQL query like:

SELECT Id, CreatedById, CreatedDate, Status, CompletedDate
    FROM AsyncApexJob
    WHERE ApexClass.NamespacePrefix = :namespace
            AND ApexClass.Name = :className

Where namespace is your namespace (leave out if you are not in a package) and className is the class name string, such as "MyExampleSchedulable".

0

Best place to start is the Monitor Asynchronous Apex trailheal module. Gives nice SOQL queries, like:

AsyncApexJob jobInfo = [SELECT Status, NumberOfErrors
    FROM AsyncApexJob WHERE Id = :jobID];
  • I don't know jobID, I have only class name or Class Id with me. How do we find out this class is already scheduled in system or not? – Jagadeesh Aug 5 at 10:13

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.