Announcement

Collapse
No announcement yet.

Auto Email pdf Template after a record is created/updated.

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

  • Auto Email pdf Template after a record is created/updated.

    Hi,
    I have 3 questions regarding pdf template.

    1. How to set system to auto email a pdf (a pdf template) when a condition is met?

    2. In an entity i have 2 fields: "Attachment" & "Image". We will upload a pdf file into the "Attachment" field and photos into "Image" field. Can I create a pdf template which combine these Attachment & Image into 1 single Pdf file?

    3. Can I set for a certain role, they only can see a specific pdf template when a condition is met? Eg: a field called "Quotation Approved" = true, then Sales Person (Role) only can see a specific PDF template in Print to PDF.

    Thank you for anyone who can help me on these.
    Last edited by CYLau; 12-20-2023, 04:04 PM.

  • #2
    I do not have an out-of-the-box-solution for alle the questions, but I guess it works.

    1. It is explained here: https://docs.espocrm.com/administrat...lapplytemplate
    and you out this code in a formula with the condition.

    2. I think, it is possible.

    3. If you use the default steps to print PDF every user will see all PDF Templates for that entity. I have a workarounfd to offer only a specific template in an antity by creating a Bootstrap Link Button to that one template I want to be printed. As espoCRM uses Bootstrap, you will not need coding. I create the button in HTML and put it into a formula, which I execute in a WYSIWYG field (in code view). The code looks as this:

    Code:
    //Button to print a certain PDF Template
    printPDF = string\concatenate('<button type="button" class="btn-xs btn-primary" style="width: 100%;">', '<a rel="noopener noreferrer"',' ',
    'href="/?entryPoint=pdf&entityType=yourEntity&entityId= ',id ,'&templateId=HERE THE ID OF THAT TEMPLATE','"',' ', 'target="_blank">',
    '<span style="color: #fff; text-decoration: none;">','Print','</span></a></button>');
    You put the field where you need it and then recalculate the record and the button will appear. Because it is a normal field it will have a label, which you can hide by putting in the resources/layout/detail.json‚Äč this code to that field:

    Code:
    "noLabel": true
    Now you have a button, which in fact is only a link formated as bootstrap button.

    The WYSIWYG button field you can then display conditional.

    How it looks:
    Click image for larger version

Name:	bootstrap-button.jpg
Views:	158
Size:	14.0 KB
ID:	100899
    Last edited by shalmaxb; 12-21-2023, 12:39 AM.

    Comment


    • espcrm
      espcrm commented
      Editing a comment
      Very interesting.

    • CYLau
      CYLau commented
      Editing a comment
      Thanks for your reply.

      For question 1, which one is insert a pdf template in an email template? I cant find this in the document.

      For question 2, do you the solution how to do it?

  • #3
    you can only insert a pdf in email template as attachment not in the body

    Comment


    • #4
      Hi,
      I still cannot find a solution to auto email a pdf template after certain condition is met.
      Example I want after an invoice is approved, the system will auto email the invoice in pdf to customer.

      ANd I also need to auto insert some images into the invoice and email to customer.
      Eg: the images/photos of job done will upload as attachment in the invoice entity. After I upload the photos, the photos will auto paste in a invoice template, and the pdf invoice will auto email to customer.

      Comment


      • #5
        I'd recommend using the Workflows tool with conditions checking and the Execute Formula Script action.

        You can send generate a PDF from a template and attach it to an email with formula: https://docs.espocrm.com/administrat...extpdfgenerate

        Comment


        • #6
          Originally posted by yuri View Post
          I'd recommend using the Workflows tool with conditions checking and the Execute Formula Script action.

          You can send generate a PDF from a template and attach it to an email with formula: https://docs.espocrm.com/administrat...extpdfgenerate
          Thanks yuri, I will try this.

          Comment

          Working...
          X