Execute scheduled Apex class code on the Developer console

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I have the following scheduled Apex code, I want to try it out on the developer console, as salesforce scheduler offers to the run the code, once an hour only.



global class examExpiryAlert implements Schedulable 

global void execute(SchedulableContext ctx)
List<Exam__c> objects = [
SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
FROM Exam__c
WHERE Exam_state__c = 'Active'];

for(Exam__c e : objects)
if(e.Expiration_Date_WF__c >= Date.today()-7)
e.day7Alert__c = True;


update objects;




how can i run this code in the developer console to execute it right away, what parts do i have to remove or add?










share|improve this question





























    up vote
    1
    down vote

    favorite












    I have the following scheduled Apex code, I want to try it out on the developer console, as salesforce scheduler offers to the run the code, once an hour only.



    global class examExpiryAlert implements Schedulable 

    global void execute(SchedulableContext ctx)
    List<Exam__c> objects = [
    SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
    FROM Exam__c
    WHERE Exam_state__c = 'Active'];

    for(Exam__c e : objects)
    if(e.Expiration_Date_WF__c >= Date.today()-7)
    e.day7Alert__c = True;


    update objects;




    how can i run this code in the developer console to execute it right away, what parts do i have to remove or add?










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have the following scheduled Apex code, I want to try it out on the developer console, as salesforce scheduler offers to the run the code, once an hour only.



      global class examExpiryAlert implements Schedulable 

      global void execute(SchedulableContext ctx)
      List<Exam__c> objects = [
      SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
      FROM Exam__c
      WHERE Exam_state__c = 'Active'];

      for(Exam__c e : objects)
      if(e.Expiration_Date_WF__c >= Date.today()-7)
      e.day7Alert__c = True;


      update objects;




      how can i run this code in the developer console to execute it right away, what parts do i have to remove or add?










      share|improve this question















      I have the following scheduled Apex code, I want to try it out on the developer console, as salesforce scheduler offers to the run the code, once an hour only.



      global class examExpiryAlert implements Schedulable 

      global void execute(SchedulableContext ctx)
      List<Exam__c> objects = [
      SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
      FROM Exam__c
      WHERE Exam_state__c = 'Active'];

      for(Exam__c e : objects)
      if(e.Expiration_Date_WF__c >= Date.today()-7)
      e.day7Alert__c = True;


      update objects;




      how can i run this code in the developer console to execute it right away, what parts do i have to remove or add?







      apex query scheduled-apex developer-console






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago

























      asked 1 hour ago









      Niveth Kumar

      215




      215




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Try:



          new examExpiryAlert().execute(null);


          context doesn't matter.






          share|improve this answer








          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • thanks a lot, this worked. Will mark as best answer
            – Niveth Kumar
            1 hour ago

















          up vote
          1
          down vote













          If you want to execute just a part of the class, you can extract the code and run that. However, Non atomic's way is best if you want all the functionality.



          List<Exam__c> objects = [
          SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
          FROM Exam__c
          WHERE Exam_state__c = 'Active'];

          for(Exam__c e : objects)
          if(e.Expiration_Date_WF__c >= Date.today()-7)
          e.day7Alert__c = True;


          update objects;





          share|improve this answer




















          • thank you Caspar Harmer
            – Niveth Kumar
            1 hour ago

















          up vote
          1
          down vote













          You can create a cron expression to execute scheduleable class from Developer console.



          String hour = String.valueOf(Datetime.now().hour());
          String min = String.valueOf(Datetime.now().minute());
          String ss = String.valueOf(Datetime.now().second());

          //parse to cron expression
          String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

          MyScheduledJob s = new MyScheduledJob();
          System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);


          Schedule Apex






          share|improve this answer




















          • thank you for your support
            – Niveth Kumar
            1 hour ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f235576%2fexecute-scheduled-apex-class-code-on-the-developer-console%23new-answer', 'question_page');

          );

          Post as a guest






























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          Try:



          new examExpiryAlert().execute(null);


          context doesn't matter.






          share|improve this answer








          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • thanks a lot, this worked. Will mark as best answer
            – Niveth Kumar
            1 hour ago














          up vote
          4
          down vote



          accepted










          Try:



          new examExpiryAlert().execute(null);


          context doesn't matter.






          share|improve this answer








          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • thanks a lot, this worked. Will mark as best answer
            – Niveth Kumar
            1 hour ago












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          Try:



          new examExpiryAlert().execute(null);


          context doesn't matter.






          share|improve this answer








          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          Try:



          new examExpiryAlert().execute(null);


          context doesn't matter.







          share|improve this answer








          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 1 hour ago









          Non Atomic Games

          561




          561




          New contributor




          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Non Atomic Games is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.











          • thanks a lot, this worked. Will mark as best answer
            – Niveth Kumar
            1 hour ago
















          • thanks a lot, this worked. Will mark as best answer
            – Niveth Kumar
            1 hour ago















          thanks a lot, this worked. Will mark as best answer
          – Niveth Kumar
          1 hour ago




          thanks a lot, this worked. Will mark as best answer
          – Niveth Kumar
          1 hour ago












          up vote
          1
          down vote













          If you want to execute just a part of the class, you can extract the code and run that. However, Non atomic's way is best if you want all the functionality.



          List<Exam__c> objects = [
          SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
          FROM Exam__c
          WHERE Exam_state__c = 'Active'];

          for(Exam__c e : objects)
          if(e.Expiration_Date_WF__c >= Date.today()-7)
          e.day7Alert__c = True;


          update objects;





          share|improve this answer




















          • thank you Caspar Harmer
            – Niveth Kumar
            1 hour ago














          up vote
          1
          down vote













          If you want to execute just a part of the class, you can extract the code and run that. However, Non atomic's way is best if you want all the functionality.



          List<Exam__c> objects = [
          SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
          FROM Exam__c
          WHERE Exam_state__c = 'Active'];

          for(Exam__c e : objects)
          if(e.Expiration_Date_WF__c >= Date.today()-7)
          e.day7Alert__c = True;


          update objects;





          share|improve this answer




















          • thank you Caspar Harmer
            – Niveth Kumar
            1 hour ago












          up vote
          1
          down vote










          up vote
          1
          down vote









          If you want to execute just a part of the class, you can extract the code and run that. However, Non atomic's way is best if you want all the functionality.



          List<Exam__c> objects = [
          SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
          FROM Exam__c
          WHERE Exam_state__c = 'Active'];

          for(Exam__c e : objects)
          if(e.Expiration_Date_WF__c >= Date.today()-7)
          e.day7Alert__c = True;


          update objects;





          share|improve this answer












          If you want to execute just a part of the class, you can extract the code and run that. However, Non atomic's way is best if you want all the functionality.



          List<Exam__c> objects = [
          SELECT Name, Exam_state__c, Expiration_Date_WF__c, day7Alert__c
          FROM Exam__c
          WHERE Exam_state__c = 'Active'];

          for(Exam__c e : objects)
          if(e.Expiration_Date_WF__c >= Date.today()-7)
          e.day7Alert__c = True;


          update objects;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Caspar Harmer

          12.2k21749




          12.2k21749











          • thank you Caspar Harmer
            – Niveth Kumar
            1 hour ago
















          • thank you Caspar Harmer
            – Niveth Kumar
            1 hour ago















          thank you Caspar Harmer
          – Niveth Kumar
          1 hour ago




          thank you Caspar Harmer
          – Niveth Kumar
          1 hour ago










          up vote
          1
          down vote













          You can create a cron expression to execute scheduleable class from Developer console.



          String hour = String.valueOf(Datetime.now().hour());
          String min = String.valueOf(Datetime.now().minute());
          String ss = String.valueOf(Datetime.now().second());

          //parse to cron expression
          String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

          MyScheduledJob s = new MyScheduledJob();
          System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);


          Schedule Apex






          share|improve this answer




















          • thank you for your support
            – Niveth Kumar
            1 hour ago














          up vote
          1
          down vote













          You can create a cron expression to execute scheduleable class from Developer console.



          String hour = String.valueOf(Datetime.now().hour());
          String min = String.valueOf(Datetime.now().minute());
          String ss = String.valueOf(Datetime.now().second());

          //parse to cron expression
          String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

          MyScheduledJob s = new MyScheduledJob();
          System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);


          Schedule Apex






          share|improve this answer




















          • thank you for your support
            – Niveth Kumar
            1 hour ago












          up vote
          1
          down vote










          up vote
          1
          down vote









          You can create a cron expression to execute scheduleable class from Developer console.



          String hour = String.valueOf(Datetime.now().hour());
          String min = String.valueOf(Datetime.now().minute());
          String ss = String.valueOf(Datetime.now().second());

          //parse to cron expression
          String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

          MyScheduledJob s = new MyScheduledJob();
          System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);


          Schedule Apex






          share|improve this answer












          You can create a cron expression to execute scheduleable class from Developer console.



          String hour = String.valueOf(Datetime.now().hour());
          String min = String.valueOf(Datetime.now().minute());
          String ss = String.valueOf(Datetime.now().second());

          //parse to cron expression
          String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

          MyScheduledJob s = new MyScheduledJob();
          System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);


          Schedule Apex







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Devendra

          4,1441320




          4,1441320











          • thank you for your support
            – Niveth Kumar
            1 hour ago
















          • thank you for your support
            – Niveth Kumar
            1 hour ago















          thank you for your support
          – Niveth Kumar
          1 hour ago




          thank you for your support
          – Niveth Kumar
          1 hour ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f235576%2fexecute-scheduled-apex-class-code-on-the-developer-console%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          White Anglo-Saxon Protestant

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          One-line joke