Beginner Help: Grand Total of Field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jyamada
    Junior Member
    • Aug 2026
    • 26

    #1

    Beginner Help: Grand Total of Field

    I was contracted to make a CRM for someone, and this is my first time doing much web development at all, so I'm a bit overwhelmed.

    I'm trying to do something simple and it feels like I'm missing something obvious. I want to get the sum of all gallons collected. I followed the forum post that said make a one to many entity, but it only ever returns zero. It doesn't throw an error, running isRelated in the sandbox returns false. (see image) Am I missing some intuition on how things are related?

    The before save script on customData is
    HTML Code:
    gallonSum = entity\sumRelated('collectionData', 'gallonsCollected');
    I am positive that those are the correct names. Both values are floats.

    Asked the client if they wanted to use the Reports from the Advanced Pack, but haven't heard back. For now let's assume they don't want to use it.

    I'm willing to write an extension, though I'm unclear how to get it set up. I have the ext-template, but I don't know how to get that into my docker instance. I used the docker compose yml the getting started guide suggested. The docs are unclear, can I just zip it up and add it while the container is running?
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 499

    #2
    entity\sumRelated aggregates records linked to the current record; it does not calculate a global total. If the formula is on CustomData but collectionData is the child link owned by another parent, isRelated will be false and the result will be zero.

    Put the total field and formula on the parent record that owns the collectionData link, then test it with saved and properly linked records. Note that saving a child will not automatically trigger a before-save formula on the parent; automatic recalculation would require Reports, a workflow, or an after-save hook/custom extension.

    An extension ZIP can be installed through Administration → Extensions while EspoCRM runs in Docker, but first confirm that the EspoCRM data directories are persistent and take a backup. If you share the two entity names, the relationship direction, and where the total should appear, we can help map it correctly or implement it as an upgrade-safe extension.
    Eblasoft | EspoCRM specialists since 2014
    Consulting · Development · Integrations · Premium Extensions
    .

    Comment


    • jyamada
      jyamada commented
      Editing a comment
      That clears it up a bit. I think the easiest way to do this would be making a dashlet, since this is a replacement for Reports.

      The parent entity as I understand it is CustomData, it should have a one to many relationship with COCollection
  • jyamada
    Junior Member
    • Aug 2026
    • 26

    #3
    Related, I tried to compile the ext-template (with npm run all) and got this back. Looked at the real estate extension and it had a merge_configs.php in the src/scripts folder, but that didn't do anything.

    HTML Code:
    Error: Command failed: php merge_configs.php
        at genericNodeError (node:internal/errors:985:15)
        at wrappedFn (node:internal/errors:539:14)
        at checkExecSyncError (node:child_process:942:11)
        at Object.execSync (node:child_process:1014:15)
        at file:///C:/Users/jayde/Documents/yei-docker/yei-crm/node_modules/espo-extension-tools/build.js:318:12
        at new Promise (<anonymous>)
        at install (file:///C:/Users/jayde/Documents/yei-docker/yei-crm/node_modules/espo-extension-tools/build.js:246:12)
        at file:///C:/Users/jayde/Documents/yei-docker/yei-crm/node_modules/espo-extension-tools/build.js:46:25 {
      status: 255,

    Comment


    • rabii
      rabii commented
      Editing a comment
      i have seen this before - it is most like to do with the fact that you didn't assign correct database name (existing one) in config-default.json or config.json if you use a custom config.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 10024

    #4
    The PHP script is run by the Espo instance (installed in the 'site' directory), but when there's no database, it cannot start. The error should be in `site/data/logs`.

    Comment


    • jyamada
      jyamada commented
      Editing a comment
      Yep. Uncaught Exception PDOException: "could not find driver" at C:\Users\jayde\Documents\yei-docker\yei-crm\site\application\Espo\ORM\PDO\MysqlPDOFactory. php line 73

      Where and how do I make the database then? The docs weren't clear on that.

      Right, mysql. I forgot about that, give me a bit
      Last edited by jyamada; 08-07-2026, 04:53 PM. Reason: Forgot a thing
  • jyamada
    Junior Member
    • Aug 2026
    • 26

    #5
    So I got mysql running, but the same MysqlPDOFactory.php error is happening. I created the database and it has the right name, I changed the port, and the user and password are correct. I'm unsure what's wrong.

    HTML Code:
         "database": {
             "host": "localhost",
             "port": 3306,
             "charset": "utf8mb4",
             "dbname": "ext_test_ext",
             "user": "root",
             "password": "admin",
             "platform": "Mysql"      },

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 10024

      #6
      Is pdo_mysql extension installed?

      Comment


      • jyamada
        jyamada commented
        Editing a comment
        That was the issue
    • yuri
      EspoCRM product developer
      • Mar 2014
      • 10024

      #7
      Database credentials are specified in config.json (in the root directory of the extension repository). https://github.com/espocrm/ext-template#configuration

      The database is just created the usual way.

      I did these steps many many times, it should work fine.

      Comment

      • jyamada
        Junior Member
        • Aug 2026
        • 26

        #8
        I got lost in the weeds and forgot I had my docker instance. I'm on windows and didn't my extension set up with apache. What files need to go into the extension zip folder?

        Never mind, found it. Okay so there is a custom dashlet now, how do i grab the data from all entities so I can make my own report?
        Last edited by jyamada; 08-07-2026, 11:26 PM. Reason: Completely missed the build folder

        Comment

        Working...