Announcement

Collapse
No announcement yet.

Print2PDF Template - Multiple Attachment Image Layout & Event Type Entity

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

  • Print2PDF Template - Multiple Attachment Image Layout & Event Type Entity

    UPDATE: Both of these issue is solved in version 5.9.2. Please see post below if you want the patch/code.


    Version EspoCRM 5.9.1

    After many attempts and failure I manage to Print Multiple Attachment to PDF. Please see this post (if you are curious) for my trial-test, other here is the final code which work good:

    This code is to Print2PDF Field type Attachment Multiple
    Final Code at the end of the day:
    Code:
    {{#each imagesIds}}
    {{imageTag width=100 height=100 ./this}}
    {{/each}}
    Anyway it look good and working fine. The issue I'm having trouble is it paragraph by paragraph. Is there any way for me to make it in a row format? So at that size, maybe I can get 4 images in a row. That is my first issue.

    I did refer to this page but that seem to be for column by column.
    https://docs.espocrm.com/user-guide/...to-pdf/#tables
    https://docs.espocrm.com/user-guide/...#each-iterator

    ---

    Second issue I'm having is Printing an Event type entity.
    I have no issue printing Meetings and Tasks as it is a default field type by using the this code:
    Code:
    {{#each meetings}}
    {{name}}
    {{/each}}
    But what I'm having trouble is to link to another Entity I call HistoryEvents. I'm not sure what it stopping it from working, I tried a variation of Parent-Child relationship linking and a few Many-to-Many but no luck. Anyone know what I need to do? Obviously this below code doesn't work out of the box:

    Code:
    {{#each historyEvents}}
    {{name}}
    {{/each}}
    Last edited by espcrm; 05-28-2020, 01:19 AM.

  • #2
    1. Not possible. It requires to create a helper that will check if an index (inside loop) is multiple of specific value, to know where to break a line.
    2. What link name do you have? 'historyEvents' ?

    Comment


    • #3
      Originally posted by yurikuzn View Post
      1. Not possible. It requires to create a helper that will check if an index (inside loop) is multiple of specific value, to know where to break a line.
      2. What link name do you have? 'historyEvents' ?
      1. Cool, guess I find a workaround at a later stage.
      2. Here is the current setup, still trying to figure out how to make it work. It is linked via Parents but it doesn't work so I create new relationship through Many-to-Many hoping it would work.

      Second picture: If I were to add a Bottom panel and use that it will work, but that double entry data. Would rather it emulate the meetings/task.
      Last edited by espcrm; 05-26-2020, 01:32 AM.

      Comment


      • #4
        Your Property entity doesn't have a link with HistoryEvent entity. Link can be created at Administration > Entity Manager > HistoryEvent > links > parent. There should be checkboxes in the bottom that create links for foreign entities.

        If you created your HistoryEvent before 5.9.0 it would require some manual changes in metadata to create that link.

        Comment


        • #5
          Originally posted by yurikuzn View Post

          If you created your HistoryEvent before 5.9.0 it would require some manual changes in metadata to create that link.
          I made this entity when it 5.7 or 5.8 (not sure), how would I do those manual change?

          With this step here: Administration > Entity Manager > HistoryEvent > links > parent

          Should it be:
          Administration > Entity Manager > HistoryEvent > Relationships > links > parent > edit?

          I played on the demo.espocrm.com and can notice a differences in my version and demo version. For me there is no checkbox, so I would need to do it manually method.

          Comment


          • #6
            custom/Espo/Custom/Resources/metadata/entityDefs/HistoryEvent.json

            In the "link" section find "parent" link and add "foreign": "historyEventChildren". Make sure json is valid, there is no trailing comma.

            Clear cache

            Then edit the relationship from entity maanger.

            Comment


            • espcrm
              espcrm commented
              Editing a comment
              Thank you. I give it a try tomorrow and report back finding.

          • #7
            Helper 'ifMultipleOf': https://github.com/espocrm/espocrm/issues/1722

            Comment


            • #8
              Finally got around to manual patching this, "ifMultipleof" code. Look good and beautiful printout.
              It took a bit of jiggling to get it to working so if anyone need help. The secret is copy/paste it in <> code view. I made a mistake pasting it normally and it didn't recognize the <br> tag, which is "break", allowing the data to be display as a row.

              Anyway here is my code if anyone want to use it for "Image Printing", my image/Multiple Attachment fieldname is: images
              Code:
              {{#each imagesIds}}
              {{#ifMultipleOf @key 4}}<br>{{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}}
              {{/each}}

              Comment

              Working...
              X