Beginner Help: Grand Total of Field

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

    #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
    • 495

    #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

    Working...