Announcement

Collapse
No announcement yet.

How to access attributes of a 'linked-to-linked' entity within a template

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

  • How to access attributes of a 'linked-to-linked' entity within a template

    Hi! I have the following concrete case:

    Entity Patient
    Entity Addresses (that stores all the addresses the Patient have/had - needed due to patient living in an area of high migratory activity)
    Entity Prescription (of medicines)

    Entity Prescription has a receipt template that needs Patient.name and Patient.Addresses.LATEST-RECORD.

    When editing the Prescription template I can see listed the attributes Patient.AddressesNames and Patient.AddressesIds, but they are 'empty' and I can't iterate over them with {{#each}} (nothing is shown).

    Is it possible to access the latest record on Patient.Addresses in any way within the Prescription template? I'm not sure templates can handle Entity->LinkedEntitity->LinkedEntity.attribute. Am I right

    If so, is it possible to create an address field in Patient entity to always store the latest Addresses record related to this Patient? This way Prescription template could only retrieve Patient.addressfield directly.

    Thanks,
    Arthur

  • #2
    Does anyone have any idea? Unfortunately it determines if I'll be able to continue with EspoCRM or not.

    If it is not clear, I can explain in another way.

    Thanks!
    Last edited by arthurmaciel; 01-28-2019, 02:13 AM.

    Comment


    • #3
      Hello,
      if you have an advanced pack you can easily do that with the workflow. You should choose the "Patient" entity as a Target entity, trigger type "After record saved". In "Conditions" section set "All" choose one or a few of the needed fields "Street", "City" and "Country" as well, and set them "equal" --> "not empty". In Actions choose "Update related record", select the "Prescription" entity, add one or a few of the appropriated fields "Street", "City" and "Country" as well, choose "field" --> "Target entity Patient field".
      This can be useful:
      1. https://www.espocrm.com/documentatio...ion/workflows/
      2. https://www.espocrm.com/video/workfl...n-in-business/

      Comment


      • #4
        Hi Maximus, unfortunately I'm developing this for free for a public health institution so we cannot afford Advanced Pack. I appreciate you effort.

        If someone else has any other idea which could be shared, I'd be grateful!

        Comment


        • #5
          Any other idea? It would really be awesome to continue with EspoCRM.

          Thanks

          Comment


          • #6
            You could mod the template engine php file

            Comment


            • #7
              tothewine, thanks for the answer. Any idea suggestion on how to do it?

              Comment


              • tothewine
                tothewine commented
                Editing a comment
                Sorry I'm not that deep in the code... but you should find some example in the documentation on how to override php classes.
            Working...
            X