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
alexbalexb 

Can't query the CronTrigger system object

I am trying to write some code to see what cron jobs currently exist in my SF org, but I'm having troubles.

 

Here's what I am trying to do in a trigger I have on a custom object.

 

 

CronTrigger existingCronJob = [SELECT Id, CronExpression FROM CronTrigger WHERE Id = :configObject.Scheduled_Email_Job_Id__c LIMIT 1];
In the Force.com IDE in Eclipse, it gives me an error "Save error: sObject type 'CronTrigger' is not supported."

 

 

 

Look here, do page search for 'CronTrigger'. It explicitly says that  "Q: Is it possible to query the last time a scheduled batch process completed? A: Yes, you can query the CronTrigger table."

http://wiki.developerforce.com/index.php/Tech_Talk:_Whats_New_in_Apex_Code_FAQ

 

So what gives? Any answers out there?

 

Thanks!

-Alex

Best Answer chosen by Admin (Salesforce Developers) 
alexbalexb

Ah, I fixed it. When I clicked 'save' in Eclipse, it sent my code and metadata to Salesforce servers. SF checked the metadata for the apiVersion, which was older (14.0), and decided that my code was invalid according to version 14.0 standards. It sounds like access to the CronTrigger object was not granted until later, so I had to tell SF that this code wants to run with the newer API version.

 

Thanks for the tip!

All Answers

Walter@AdicioWalter@Adicio

You have to upgrade your IDE to Winter 11 (21.0). Then the object is supported. It may have been release a little prior to 21.0 but the latest version would do the trick.

alexbalexb

I do have the latest Force.com IDE. I'm pretty sure that there is no version 21.0 for the Eclipse plugin. I currently have version 20.0. I went to the "Force.com Start Page" in the Eclipse browser and clicked "Check for Updates" in the upper-right and it says that I'm up to date.

 

Any other suggestions?

alexbalexb

Ah, I fixed it. When I clicked 'save' in Eclipse, it sent my code and metadata to Salesforce servers. SF checked the metadata for the apiVersion, which was older (14.0), and decided that my code was invalid according to version 14.0 standards. It sounds like access to the CronTrigger object was not granted until later, so I had to tell SF that this code wants to run with the newer API version.

 

Thanks for the tip!

This was selected as the best answer