Save pdf after e-signature

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muulox
    Member
    • Jan 2022
    • 31

    Save pdf after e-signature

    Hello,

    We have implemented electronic signature documents for EspoCRM.
    Accounts have Contracts, the customer signs the contract, we have a pdf print template - ex: "Customer contract", I want the pdf to be saved as an attachment to the customer contract after the customer has signed the contract and we updated the SIGNED field, after which it should be saved in Account-Contract Attachments. So that we don't use sheets anymore. The customer can view the contract as an attachment in the customer portal.

    How can we create a workflow like this to automatically save pdf to contract attachments?

    Thank you!​
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    It's hard to tell for me as I don't know how the electronic signature functionality works. What records are produces in Espo upon signing.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • emillod
      Active Community Member
      • Apr 2017
      • 1405

      #3
      I believe you should simply create a PDF template which will contain all required information, including image with eSignature.
      And then you can simply create a workflow which will execute formula which generates PDF based on specific trigger and it should save it as an attachment to this record.

      Comment


      • muulox
        muulox commented
        Editing a comment
        Hello,
        I created the PDF Teamplate which will contain all required information, including image with eSignature.
        My question is the code for the workflow. To generate PDF according acording to the teamplate id, and save to the generated pdf at the client -> contracts - attachments.
        Thank you!
    • muulox
      Member
      • Jan 2022
      • 31

      #4
      i created a code but dosent working:

      PHP Code:
      $pdfTemplateId = '675208b87d2dd9fcd';
      $entityId = entity\attribute('id');
      
      // Generate the PDF and create an attachment
      $attachmentId = ext\pdf\generate(
      'CInventar',
      $entityId,
      $pdfTemplateId,
      'CInventar' . $entityId . '.pdf'
      );
      
      $documentId = record\create('Document',
      'name', 'CInventar' . $entityId, // Numele documentului
      'type', record\attribute('Attachment', $attachmentId, 'type'),
      'size', record\attribute('Attachment', $attachmentId, 'size'),
      'fileContent', record\attribute('Attachment', $attachmentId, 'fileContent'),
      'storage', record\attribute('Attachment', $attachmentId, 'storage')
      );
      
      record\link('CInventar', $entityId, 'documents', $documentId);​​ 
      
      Last edited by muulox; 12-09-2024, 05:06 PM.

      Comment

      • emillod
        Active Community Member
        • Apr 2017
        • 1405

        #5
        Please look at this: ext - EspoCRM Documentation
        this will not work AFAIK: 'CInventar' . $entityId . '.pdf'

        Comment

        • muulox
          Member
          • Jan 2022
          • 31

          #6
          Whit this code pdf-is generated.I see in//data/upload , but the attachment is not attached in entity documents. A file is created in Documents but the attachment is empty.


          PHP Code:
          // Define the ID of the template PDF
          $pdfTemplateId = '675208b87d2dd9fcd'; // Înlocuiește cu ID-ul real al template-ului tău
          $entityId = entity\attribute('id'); // ID-ul entității curente (de exemplu, CInventar)
          
          
          // Generate the PDF and create an attachment
          $attachmentId = ext\pdf\generate(
              'CInventar', // Tipul entității
              $entityId,   // ID-ul entității
              $pdfTemplateId, // ID-ul template-ului PDF
              'CInventar_.pdf' // Numele fișierului pentru atașament
          );
          
          
          // Obține conținutul atachment-ului PDF
          $fileContent = record\attribute('Attachment', $attachmentId, 'fileContent');
          
          
          // Creează un document în EspoCRM
          $documentId = record\create('Document',
              'name', 'CInventar_' , // Numele documentului
              'type', record\attribute('Attachment', $attachmentId, 'type'), // Tipul fișierului
              'size', record\attribute('Attachment', $attachmentId, 'size'), // Dimensiunea fișierului
              'global', record\attribute('Attachment', $attachmentId, 'global'), // Marcare ca document global
              'fileContent', $fileContent, // Conținutul fișierului PDF
              'storage', record\attribute('Attachment', $attachmentId, 'storage'), // Tipul de stocare
          
          );
                  record\create('CInventar', $entityId,
                      'documents' => $documentId // Salvează ID-ul documentului generat
                  );
          Attached Files

          Comment

          • muulox
            Member
            • Jan 2022
            • 31

            #7
            Any sugestions?

            Comment

            Working...