Announcement

Collapse
No announcement yet.

pdf template with loop doesn't work

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

  • pdf template with loop doesn't work

    Hi all,

    as a new forum user I firstly want to thank you all for this absolutely astonishing piece of software! Still discovering every day new possibilities.

    This is my first issue after reading lot's of post but couldn't find the answers, something that would look very easy:

    1. I create an empty pdf template
    2. according to the docs (see link) it looks simple, only add {{#each contacts}} Contact name: {{name}} {{/each}} in the body (see screenshot)
    3. when selecting contacts and choose 'print to pdf' I get x empty pages
    4. when using another template without the #each it does shows the desired information

    What am I doing wrong?

    Click image for larger version

Name:	Schermafbeelding 2021-04-20 om 11.04.45.png
Views:	358
Size:	40.6 KB
ID:	69825

  • #2
    Hello,

    you can not loop a EntityType = Contact and {{#each contacts}} !!
    in these case, sample EntityType = Account and then {{#each contacts}} will work

    for your request, you need in ListView of Contact.. select some contact (not all, limitation of print-pdf) and then print-to-pdf and template {{name}} {{firstName}} so..

    Comment


    • #3
      Hi item,

      thanks for your explanation why #each contacts only works with EntityType = Account. Your suggestion created a multiple page pdf, with on each page a name.

      The thing I was hoping for with the loop is to create i.e. one page listing only names (for example).

      It was a pre-study to create a template for printing address labels in a 3x8 table, is that possible anyway?

      Comment


      • #4
        Hello,

        each is for related entity : i give Account sample, but you can each all related entity.
        now i understand, i know in the forum on the past same request and if i remember no solution.
        maybe is more simple export as xlsx and then make it with word.

        Comment


        • #5
          Thanks for clarification, it's a pity that something simple and core as printing a pdf with address labels is so hard or impossible without using external apps like Word.

          Anyway: I'm still wondering how I can create (let's say a checklist) like 1 page with 10 names (contacts selected)?

          Comment


          • #6
            Just to clarify some info for your reference (and also to welcome you to the forum).

            For #each to work it need to have an relationship from one entity to another. For example

            Account: Business ABC
            employed contact: Contact1, Contact2, Contact3...

            Each #each contact in the Account template will get you list of all Contact within the Account.

            You can't just #each contact in a contact, not unless you create a relationship in Contact. For example, with one of my Relationship I create "Referral Contact", so I can link all the name that a client refer to us. Then you can use #eachReferalContact.

            If you want to create a "template list" i suppose you could use Target List to create a list of contact and use #each tag on that. Or link it all to an Account, but at the end of the day it need a relationship either 1-to-many or many-to-many, etc.

            If you want to print out a list I suppose a Print screen or print browser directly also work, but it look ugly. You can also do Export to Excel/CSV and print from there if you want a list.

            After all that said, I think target list work best for your situation.
            ---


            Also finally to plug in my "Wiki" thread as you are new here: https://forum.espocrm.com/forum/gene...crm-and-design

            Comment


            • #7
              esforim Thanks for the hints and explanation! Indeed I will try the Target list suggestion!!

              Comment

              Working...
              X