How to get job id or job name from current running scheduled job

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












Can we get job id or job name from current running job?
For example:



global class MySchedule implements Schedulable 
global void execute(SchedulableContext sc)

Id jobId = sc.getJobId();
String jobName = sc.getJobName();




Is there any workaround to get the current job id or job name ?










share|improve this question



























    up vote
    1
    down vote

    favorite












    Can we get job id or job name from current running job?
    For example:



    global class MySchedule implements Schedulable 
    global void execute(SchedulableContext sc)

    Id jobId = sc.getJobId();
    String jobName = sc.getJobName();




    Is there any workaround to get the current job id or job name ?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Can we get job id or job name from current running job?
      For example:



      global class MySchedule implements Schedulable 
      global void execute(SchedulableContext sc)

      Id jobId = sc.getJobId();
      String jobName = sc.getJobName();




      Is there any workaround to get the current job id or job name ?










      share|improve this question













      Can we get job id or job name from current running job?
      For example:



      global class MySchedule implements Schedulable 
      global void execute(SchedulableContext sc)

      Id jobId = sc.getJobId();
      String jobName = sc.getJobName();




      Is there any workaround to get the current job id or job name ?







      scheduled-apex scheduled-job






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Rival

      1209




      1209




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Yes. If you call getTriggerId() on your SchedulableContext, it will provide the Id of your CronTrigger, and thence the CronJobDetail for this Schedulable.



          From there, you can do



          CronTrigger ct = [SELECT CronJobDetail.Name FROM CronTrigger WHERE Id = :myId];


          and that'll give you the name.






          share|improve this answer




















            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%2f233020%2fhow-to-get-job-id-or-job-name-from-current-running-scheduled-job%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            Yes. If you call getTriggerId() on your SchedulableContext, it will provide the Id of your CronTrigger, and thence the CronJobDetail for this Schedulable.



            From there, you can do



            CronTrigger ct = [SELECT CronJobDetail.Name FROM CronTrigger WHERE Id = :myId];


            and that'll give you the name.






            share|improve this answer
























              up vote
              3
              down vote



              accepted










              Yes. If you call getTriggerId() on your SchedulableContext, it will provide the Id of your CronTrigger, and thence the CronJobDetail for this Schedulable.



              From there, you can do



              CronTrigger ct = [SELECT CronJobDetail.Name FROM CronTrigger WHERE Id = :myId];


              and that'll give you the name.






              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                Yes. If you call getTriggerId() on your SchedulableContext, it will provide the Id of your CronTrigger, and thence the CronJobDetail for this Schedulable.



                From there, you can do



                CronTrigger ct = [SELECT CronJobDetail.Name FROM CronTrigger WHERE Id = :myId];


                and that'll give you the name.






                share|improve this answer












                Yes. If you call getTriggerId() on your SchedulableContext, it will provide the Id of your CronTrigger, and thence the CronJobDetail for this Schedulable.



                From there, you can do



                CronTrigger ct = [SELECT CronJobDetail.Name FROM CronTrigger WHERE Id = :myId];


                and that'll give you the name.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                David Reed

                20.3k31640




                20.3k31640



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f233020%2fhow-to-get-job-id-or-job-name-from-current-running-scheduled-job%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke