Generate PDF and automatically relate it to the record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kpuc
    Member
    • Nov 2020
    • 40

    Generate PDF and automatically relate it to the record

    Hello Lads,
    Happy New Year...

    I'm thinking of a way to automatically generate a PDF with the information from a target record and after the PDF is generated -> To automatically connect the PDF as a File (field) to the same target record.

    For example we could have a contract which can be easily generated to a PDF, but after the PDF generation, the file could be easily downloadable from the same record Details view.

    Any ideas would be very appreciated.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1603

    #2
    Perhaps this helps: https://forum.espocrm.com/forum/gene...-pdf#post63362

    Comment

    • emillod
      Active Community Member
      • Apr 2017
      • 1405

      #3
      Hello.
      we have something like that. Our script generate invoice based on specific template and relate generated file as attachment to invoice record.
      Unfortunatelly i can't publish that for free.. Maybe there is other user which can post solution

      Comment

      • item
        Active Community Member
        • Mar 2017
        • 1476

        #4
        Hello,

        maybe (certainly i think) this is possible with AdvancedPack easily ! BPM !

        Regards
        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

        Comment

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #5
          I thought I wrote a "learning" about PDF-Template creation by Formula but I guess I haven't.

          Yes, the simplest way to create PDF without need extensions and coding is to use Formula which can all be done using the GUI admin. The formula is quite straight forward and the example is a working from what I remember. I just removed the email code so it doesn't email and only have there as an attachment. I create an File/Attachment field and use the formula to generate that PDF if the Status = "Close"

          Here is a rough formula I used (which I disabled because it need tweaking)

          Code:
          ifThen(agreementstatus='Finalize', description = ext\pdf\generate('Agreement', entity\attribute('id'), '5f0bfb03dfd1853d6', 'test.pdf'))
          (Hopefully it work) Anyway here the breakdown in case you want to adapt to it to your formula;

          if the field "Agreement Status" is Finalize, then in the Description field generate the PDF in my Agreement entity, the PDF I want to use it unique ID is (URL) 5f0bfb03dfd1853d6, and name this PDF as 'test.pdf'

          Code:
          ext\pdf\generate(ENTITY_TYPE, ENTITY_ID, TEMPLATE_ID, [FILENAME])

          Comment


          • item
            item commented
            Editing a comment
            esforim : just important is writed
            lecon 1 :
            agreementstatus='Finalize' ....

            one "=" => assignement !
            sample :
            item = "is a object" // assignement
            print(item) => "is a object"

            lecon 2 :
            agreementstatus=='Finalize' .... (use in "if" and so )

            two "==" => compare
            sample :
            item = "item"; // assignement
            item == "is a object" // compare
            print(item) => "item"
            result => false ! ... item it's me
        Working...