Dev: Signatory Log Integration
1. Overview
The uploadAndGetFileIdOFSignedDocument (Upload Signed Document from E-Signature Log Record) method is a global Invocable Action provided by the DRTE package. It is designed to be called within a Salesforce Flow after a signing process is completed.
The method performs the following server-side operations:
- PDF Generation: Renders the finalized document (including signatures) using the internal DRTE PDF engine.
- File Creation: Generates a standard Salesforce ContentVersion (File).
- Automatic Linking: Attaches the generated File to the specified E-Signature Log record.
- ID Return: Returns the unique ID of the new File for use in subsequent Flow steps (e.g., sending an email with the attachment).
2. Input Parameters
When configuring the "Apex Action" in Flow, the following input variables are available:
Parameter | API Name | Data Type | Required | Description |
Record ID | recordId | Text | Yes | The Salesforce ID of the E-Signature Log record. |
Envelope Token | token | Text | Yes | The unique security token/Envelope ID associated with the signing request. |
File Name | fileName | Text | No | The desired name for the PDF file (omit ".pdf"). Defaults to the Token value if left blank. |
Footer Text | footerText | Text | No | Custom text to appear in the footer of the generated PDF. |
Header Image URL | headerImageURL | Text | No | A public URL for a logo to be rendered in the PDF header. |
3. Output Values
Parameter | Data Type | Description |
Output Value | Text (String) | The ID of the generated ContentVersion record (The File ID). |
4. How to Use in Salesforce Flow
Step 1: Trigger the Flow
Typically, this action is used in a Record-Triggered Flow on the pscdnyrichtext__ESignature_Log__c object when the Status changes to "Completed" or "Signed."
Step 2: Add the Apex Action
- In the Flow Builder, add a new Action element.
- Search for "Upload Signed Document from E-Signature Log Record".
- Map your variables:
- Record ID: {!$Record.Id}
- Envelope Token: {!$Record.pscdnyrichtext__Token__c}
- File Name: "Executed_Contract_{!$Record.Name}"
Step 3: Utilize the Output
Since the action returns the File ID, you can add a subsequent step to:
- Post the file to a Chatter feed.
- Send an Email Alert with the File attached (using the ContentVersion ID).
- Update the parent record (e.g., Opportunity) with a link to the new file.
5. Technical Considerations & Security
- PDF Rendering Context: This method uses Page.getContentAsPDF(). Please note that this is a callout-like operation. If you are calling this from a loop, ensure you stay within Salesforce governor limits for heap size and CPU time.
Atomic Operation: The file insertion and the link to the recordId happen in a single transaction. If the file creation fails, the transaction rolls back to maintain data integrity.