Announcement

Collapse
No announcement yet.

Cron job to recalculate formulas

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cron job to recalculate formulas

    Hello,

    I'm new to espo and I was wondering if there is a solution to make a custom cron job, that will recalculate formulas for all entities. I don't have Advanced pack with workflows yet. Thanks

  • #2
    Hi there,
    The only way to achieve this is to develop your own custom job (needs some code skills).
    Here is the useful manual https://docs.espocrm.com/development/scheduled-job/

    Comment


    • #3
      This would be interesting to achive, but it is beyond my skills. Could we use this

      This tutorial describes how to create a simple extension based on a custom implementation and shows how to use 'Modules' to segregate customizations instead of having everything in the 'Custom' namespaces, making it much easier to manage changes and troubleshooting for your custom code. The custom implementation described here


      somehow? telecastg what do you think?

      Comment


      • #4
        My problem is, that I have some fields in my entity which are automatically calculated based on espo formula.

        Everytime I need to see updated field I need to resave it, or use convert currency button which surprisingly works as refresh for formula (cache wipe also works but it is not an option)

        Unfortunatelly, I'm not the best coder and I'm still learning PHP stuff thanks to espo Thank you for your patience and help guys.

        Comment


        • #5
          Hello,

          yes nice request and in my idea is easy but not perfect

          the perfect solution is in admin section : can select some entity .. (<= telecastg, can you do that ?). or in config like countryList ?

          a job who loop after these entity List and save record. <= i do that .. it's basic

          my idea is so but not it's hard

          PHP Code:
          $pdo $this->getEntityManager()->getPDO();

          $sql "SHOW TABLES";
          $sth $pdo->prepare($sql);
          $sth->execute();
          $tableList$sth->fetchAll();
          foreach (
          $tableList as $table) {
          $table $table[0] ;  // need to adapt to espoCRM camelCase, certainly issue with middle table and other table not used (log, actionHistory) 

          Comment


          • #6
            Originally posted by shalmaxb View Post
            This would be interesting to achive, but it is beyond my skills. Could we use this

            https://forum.espocrm.com/forum/deve...able-extension

            somehow? telecastg what do you think?
            Hi shalmaxb , yes, I think that the back-end functionality could be triggered by a custom job instead of by clicking a button in the front end.

            I don't have any code samples and I am very busy at the moment with our application to provide more detailed instructions but essentially all you have to do is to create a custom job as Maximus indicated https://docs.espocrm.com/development/scheduled-job/ and then invoke the back end controller and function created in the posting that you referenced.

            In other words, instead of using an Ajax call to invoke a back-end controller and function, as you would do in "Step 1" here https://forum.espocrm.com/forum/gene...7904#post67904 you will be using the custom job to invoke them here
            Click image for larger version  Name:	tempsnip.png Views:	26 Size:	50.8 KB ID:	68974
            Last edited by telecastg; 03-27-2021, 06:29 PM.

            Comment


            • #7
              Originally posted by item View Post
              Hello,

              yes nice request and in my idea is easy but not perfect

              the perfect solution is in admin section : can select some entity .. (<= telecastg, can you do that ?). or in config like countryList ?

              a job who loop after these entity List and save record. <= i do that .. it's basic

              my idea is so but not it's hard

              PHP Code:
              $pdo $this->getEntityManager()->getPDO();

              $sql "SHOW TABLES";
              $sth $pdo->prepare($sql);
              $sth->execute();
              $tableList$sth->fetchAll();
              foreach (
              $tableList as $table) {
              $table $table[0] ; // need to adapt to espoCRM camelCase, certainly issue with middle table and other table not used (log, actionHistory) 
              Hi, how can i use this formula? Can you help please?

              Comment

              Working...
              X