0

I'm looking for a way to retrieve the signed document from the Salesforce Files object after the document has been saved back to Salesforce. Right now, I have 2 documents in my files object, one unsigned and one signed. How do I get the signed one using Apex?

I have tried the Apex Toolkit but could not find a method that I needed.

1 Answers1

0

You can differentiate the document that is written back from DocuSign from other documents by setting the specific name format to the writeback document.

And you can specify the name format of it through ApexToolkit. For example, if you want to set the file name as "document name + envelope status", you would need to set WRITE_BACK_NAME_ENVELOPE_STATUS as the value for the second argument of dfsle.Document.WriteBack method. Please refer to the exmaple code below:

myEnvelope = myEnvelope.withOptions(new dfsle.Envelope.Options(
        false,
        new dfsle.Document.WriteBack(
            mySourceId,
            dfsle.Document.WRITE_BACK_ENVELOPE_STATUS_PDF,
            true,
            true
        ),
        new Map<String, Map<String, Object>> {
            dfsle.Envelope.STATUS_COMPLETED => new Map<String, Object> {
                'Opportunity.StageName' => 'Closed Won'
            }
        },
        new Map<String, Map<String, Object>>()
    ));

There are a few other name format options you can use. More information about it is described in the ApexToolkit reference:

1: https://developers.docusign.com/docs/salesforce/apex-toolkit-reference/document.html 2: https://developers.docusign.com/docs/salesforce/apex-toolkit-reference/document.html