Where to best put the logic for calculated, not-storable fields?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ingo
    Junior Member
    • Jan 2026
    • 1

    #1

    Where to best put the logic for calculated, not-storable fields?

    Hi all,
    I am working on an extension for the management of courses (e.g. for a gym).
    There are several custom entities, one of them is CourseManagerCourse another is CourseManagerRegistration.
    The second has a belongsTo link to the first.
    I have a not-storable, read-only field in CourseManagerRegistration which calculates a registration code. At the moment, I implemented it as a Espo\Core\FieldProcessing\Loader (registered in recordDefs as listLoader and readLoader).
    Everything works well so far except in PDF templates. There, the fields are not populated when the registrations are loaded from inside a Course.
    And here comes my question: As I see it, the population of the field could also be implemented by extending the Entity class and override the get method. Or I could use the pdfDefs and implement a PdfDataLoader. Perhaps Hooks would also be an option?
    What is the best way to go here?
    Thanks in advance for your answers :-)
    Ingo
  • emillod
    Active Community Member
    • Apr 2017
    • 1550

    #2
    Hello ingo
    you're doing probably something wrong, because we have a lot of notStorable fields, and they're working normally on all PDF's. I'm adding for example {{delayedInvoicesAmount}} to PDF template and tada

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9570

      #3
      Hi,

      loaderClassName in entityDefs > fields > {field} can also be used. https://docs.espocrm.com/development...oaderclassname
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      Working...