With Apex, you can use the dfsle.Envelope.withOptions method in order to writeback combined documents under Salesforce.
To write back completed documents and update the Opportunity stage when an envelope is completed, you can use the following code:
myEnvelope.withOptions(new dfsle.Envelope.Options(
// Whether to populate auto-place tags for default roles
false,
new dfsle.Document.WriteBack(
// Where to link the completed document(s)
opportunityId,
// The completed document(s) file name format
dfsle.Document.WRITE_BACK_ENVELOPE_STATUS_PDF,
// Whether to combine all the documents into a single PDF
true,
// Whether to include the Certificate of Completion (CoC)
true),
// Envelope status event updates
new Map<String, Map<String, Object>> {
// Set Opportunity.StageName to "Closed Won" upon completion
dfsle.Envelope.STATUS_COMPLETED => new Map<String, Object> {
'Opportunity.StageName' => 'Closed Won'
}
},
// Recipient status event updates
new Map<String, Map<String, Object>>()));
You will find an example in this blog article: https://www.docusign.com/blog/developers/whats-new-summer-21-apex-toolkit
Ashley
DocuSign Developer Support