salesforcedocusignapidocusignapextoolkit

DocuSign Apex Toolkit - Get PDF byte stream of envelope documents


How do I get the PDF byte stream of all the documents within an envelope using the Apex Toolkit?

I can't seem to find the right method to do this from the documentation: https://developers.docusign.com/docs/salesforce/apex-toolkit-reference/documentservice.html

I'm looking for an Apex Toolkit equivalent way of doing this: https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/get/#:~:text=To%20retrieve%20a%20single%20document,just%20the%20certificate%20of%20completion.

Some sample code of how to do this is appreciated.


Solution

  • The Apex Toolkit does not support getting the bytes of the document like you asked. If you just need to write it back to a SF record - there's a way to do that. If you need to document for other purposes, you can either make your own API call directly from SF. See https://youtu.be/mJ082IPwIWs for information about doing that.

    Another option is to use Docusign Connect, and a webhook will call your code and you can then use the document bytes from the webhook and do what you want with the document.

    The another very new option is to use Docusign new extension apps and use a Document writeback extension point where your extension (if installed by user) then gets the bytes and your code can do what you want.

    Lastly, you can use IPAAS tools like PowerAutomate that can make the API calls for you and you get the bytes to do as you want if you create a no-code workflow in these tools.