Hi Team,
I am working on a Salesforce integration using the DocuSign Apex Toolkit, and I need to achieve the following:
- Send multiple documents (a Visualforce page converted to a PDF and a DocuSign template) as part of a single envelope.
- After all recipients sign the envelope, combine these documents into a single merged PDF.
Here's a brief outline of my current implementation:
- I generate a PDF from a Visualforce page and store it in Salesforce.
- I retrieve a pre-configured DocuSign template using its unique ID.
- I use the
dfsle.Envelope
class to attach both documents to an envelope and send it for signing using thedfsle.EnvelopeService.sendEnvelopes
method. - I retrieve the status of the sent envelopes using
dfsle.StatusService.getEnvelopeStatus
.
Code Excerpt:
Apex Code:
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(orderRec.Id)); myEnvelope.withRecipients(new List<dfsle.Recipient> { dfsle.Recipient.fromSource(orderRec.Owner.Name, orderRec.Owner.Email, null, 'Owner', new dfsle.Entity(orderRec.Id)) }); myEnvelope.withDocuments(new List<dfsle.Document> { dfsle.Document.fromFile(documentMap.get(orderRec.Id)), dfsle.Document.fromTemplate( Test.isRunningTest() ? dfsle.UUID.randomUUID() : dfsle.UUID.parse(System.label.Marketplace_Docusign_Id), 'Marketplace Commission Reduction Authorization Document Email' ) }); envelopesToSend.add(myEnvelope);
I’ve successfully sent the documents for signing. However, I want to ensure that the two documents are automatically merged into one single PDF after signing, so it can be saved as a single file in Salesforce.