Save pdf after e-signature

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • partomas
    commented on 's reply
    It's not so important " how the electronic signature functionality works" but from my point it's more important how to store these signed PDF's outside all "Uploads", to ensure their security. We has similar question with storing Contracts.

  • muulox
    replied
    I figured out :
    PHP Code:
    // Define the ID of the template PDF
    $pdfTemplateId '675208b87d2dd9fcd';
    $entityId entity\attribute('id');


    $inventarName record\attribute('CInventar'$entityId'name'); // Name


    // Generate the PDF and create an attachment
    $attachmentId ext\pdf\generate('CInventar'$entityId$pdfTemplateId$inventarName);



    // Create Document
    $documentId record\create('Document',
        
    'name'$inventarName,
        
    'status''Active',
        
    'fileId'$attachmentId // Asociezi ID-ul atașamentului
    );

    record\relate('CInventar'$entityId'documents'$documentId); 

    Leave a comment:


  • muulox
    replied
    The PDF document is generated, I see in: data/Upload/4654565466. The document is generated whit name: CInventar, but the generated PDF is not attached to the document. I have tried many variations, but I don't know what I am doing wrong. I am attaching the code. Thank you for your help!"

    entity : mx.com/#CInventar
    Inventar cInventar one-to-many documents Document
    here 'cInventar' is whit lower case ! - this i se a problem.?


    PHP Code:
    // Define the ID of the template PDF
    $pdfTemplateId '675208b87d2dd9fcd';
    $entityId entity\attribute('id');


    // Generate the PDF and create an file - this is working!
    $attachmentId ext\pdf\generate(
        
    'CInventar',
        
    $entityId,
        
    $pdfTemplateId,
        
    'CInventar.pdf'
    );

    $fileContent record\attribute('Attachment'$attachmentId'fileContent');
    $attachmentType record\attribute('Attachment'$attachmentId'type');
    $attachmentSize record\attribute('Attachment'$attachmentId'size');
    $attachmentGlobal record\attribute('Attachment'$attachmentId'global');


    // the document is created whitout the pdf attachment/file
    $documentId record\create('Document',
        
    'role''Attachment',
        
    'type'$attachmentType,
        
    'size'$attachmentSize,
        
    'fileContent'$fileContent,
        
    'global'$attachmentGlobal,
        
    'name''CInventar.pdf',
        
    'storage'record\attribute('Attachment'$attachmentId'storage'),
        
    'sourceId'$attachmentId,
        
    'entityType''CInventar',
        
    'entityId'$entityId //

    );
    ​ 

    Leave a comment:


  • muulox
    replied
    Any sugestions?

    Leave a comment:


  • muulox
    replied
    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

    Leave a comment:


  • emillod
    replied
    Please look at this: ext - EspoCRM Documentation
    this will not work AFAIK: 'CInventar' . $entityId . '.pdf'

    Leave a comment:


  • muulox
    replied
    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.

    Leave a comment:


  • muulox
    commented on 's reply
    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!

  • emillod
    replied
    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.

    Leave a comment:


  • yuri
    replied
    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.

    Leave a comment:


  • muulox
    started a topic Save pdf after e-signature

    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!​
Working...