Search code examples
salesforceapex-code

Apex Scheduler Salesforce, execution error


I have a big problem with apex scheduler. I've always get this error message, when I try to execute the scheduler: "Global type must be contained inside of a global class"

This is the code example:
global class updateData implements Schedulable { global void execute (SchedulableContext SC) { DataContact dContact = new DataContact(); dContact.UpdateContact(); } }

Thanks!

Jay


Solution

  • It looks like you are trying to execute this code inside the Developer Console. The Developer Console does not really support creating global classes (which means you can't implement the Schedulable interface inside it). If you are just trying to anonymously call UpdateContact, then you can simply type this into the Developer Console:

    DataContact dc = new DataContact();
    dc.updateContact();
    

    If you are trying to create a schedulable object to schedule calls to DataContact then you should create an Apex class with the code that you posted and then schedule it using the 'Schedule Apex' button on the Apex Classes page.