Schedule daily task to create on by its own

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandra
    Junior Member
    • Nov 2021
    • 7

    Schedule daily task to create on by its own

    Can I configure a workflow like "Schedule daily task to create on by its own" for my backups? Please share any doc's/video. Thanks for your help.
  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #2
    Yes, you can. You just have to setup a job:

    And also you can plan specific job in hook for example:
    https://dubas.pro/c/?ea76adbef1ae1b7...inRD7abPnnhhE9

    Comment


    • chandra
      chandra commented
      Editing a comment
      Hi Bro, Do you have any code for custom job example? Thanks for your help. I am very new to ESPO/PHP
  • chandra
    Junior Member
    • Nov 2021
    • 7

    #3
    Thanks for your response. I will try your link.

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #4
      Hi chandra
      Just an addition when you create you custom job, you don't need a hook to schedule it, in fact the crm will pick it up and you can schedule it (through UI) by creating a new scheduled Job under Admin/Schedule Jobs/ (Create Schedule Job) button. after that you can select from the list your custom job and schedule it. see attached screenshot. I have just gone through this lately and it works fine.
      Attached Files
      Rabii
      Web Dev

      Comment


      • chandra
        chandra commented
        Editing a comment
        HI Rabi, Schedule jobs I have created as you said. I am worried about custom job its not working for me. Do you have any code for custom job?
        Thanks for your help. I am very new to ESPO/PHP
    • chandra
      Junior Member
      • Nov 2021
      • 7

      #5
      Thank you so much Rabii....appreciated your help

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #6
        Hi chandra

        Please see below a code, i have created a new folder under custom\Espo\Custom\Jobs the folder name is jobs and i have placed all my current jobs there, see below a custom php job for my application that increments a field by one (which i have scheduled to be run each day at 1:10 am), file name UpdateClaimDwellTime.php :

        Code:
        <?php
        namespace Espo\Custom\Jobs;
        
        use Espo\Core\ORM\EntityManager;
        use Espo\Core\Job\JobDataLess;
        
        class UpdateClaimDwellTime implements JobDataLess
        {
        protected $entityManager;
        
        public function __construct(EntityManager $entityManager)
        {
        $this->entityManager = $entityManager;
        }
        
        public function run(): void
        {
        $list = $this->entityManager
        ->getRepository('Claim')
        ->where([
        'stage!=' => ['Invoice Settled', 'Failed Processing']
        ])
        ->find();
        
        foreach ($list as $e) {
        $dwellTime = $e->get('dwellTime');
        $e->set('dwellTime', $dwellTime + 1);
        $this->entityManager->saveEntity($e);
        }
        }
        }
        Let me know if that helps, otherwise you can share what you want to achieve and i might help, always happy to help if i could.

        Cheers
        Rabii
        Web Dev

        Comment


        • chandra
          chandra commented
          Editing a comment
          Thank you so much Rabii,,,, I have followed same whatever you assisted,, created Jobs folder under that i have created same file name called UpdateClaimDwellTime.php and copy n paste your code and saved,
          Is this task php will run automatically , or do I need anything more?

        • rabii
          rabii commented
          Editing a comment
          you need to schedule the time from administration / scheduled jobs (create a new one and select your custom job and give it a cron time to run), see my comments below
      • chandra
        Junior Member
        • Nov 2021
        • 7

        #7
        These are my schedule jobs

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #8
          Hi chandra

          Once you created the custom job, when you go to administration -> Scheduled Jobs (then on top right of the page click on create scheduled job) and you will see a page where you can select your job from list (you will find your custom job in the list) choose your custom job and give it a cron time execution. see attached screenshot.
          Attached Files
          Rabii
          Web Dev

          Comment


          • chandra
            chandra commented
            Editing a comment
            This is my path: public_html/custom/Espo/Custom/Jobs/UpdateClaimDwellTime.php and schedule Jobs its not showing UpdateClaimDwellTime.

            Please find the below screen shot.. Thank you
        • chandra
          Junior Member
          • Nov 2021
          • 7

          #9

          Comment

          • chandra
            Junior Member
            • Nov 2021
            • 7

            #10
            the main purpose of this is "able to create a daily task on its own for my backups check"

            Comment


            • rabii
              rabii commented
              Editing a comment
              what do you mean by task for your backups check? can you explain further

            • chandra
              chandra commented
              Editing a comment
              Schedule daily task to create on its own..(Backup status check)
          • chandra
            Junior Member
            • Nov 2021
            • 7

            #11
            Maybe I have not created workflow properly. Do you have any related workflow kindly share with me. Thank you
            Last edited by chandra; 12-16-2021, 06:55 PM.

            Comment

            Working...