[SalesForce] DocuSign Custom Button

I am fighting with a javascript custom button, I would like to add the behavior to auto populate automatically over the DocuSign envelope the documents.

I'm not able to find a way to make this work

enter image description here

I have already read the below link, but I am stuck.

https://support.docusign.com/guides/dfs-admin-guide-add-send-with-ds-button-to-quotes

Best Answer

From what I recall in making customizations to DocuSign for Salesforce (DSFS for short) for my company, you can't attach a document to the envelope using Javascript.

In my case, sending quotes out to customers via DocuSign, DocuSign automatically picks up anything (and everything) stored in an Attachment record where the ParentId field matches the Id of the record that you're initiating the envelope from (i.e. the 'SourceID' parameter that DSFS can accept).

You could probably use Javascript to prompt for a file, and then proceed to save it as an Attachment in Salesforce...but it sounds like you're getting to the point where it makes more sense to develop a custom visualforce page (with a controller extension) to take care of this for you. The added benefit to that is that buttons that redirect users to a visualforce page are allowed with the Lightning Experience (whereas Javascript buttons are not).

If you don't need any user interaction besides clicking the button (that is to say, the document you want to send already exists, or can be automatically generated), then your visualforce page can literally be one line

<apex:page standardController="YourObjectNameHere" extensions="YourExtensionNameHere" action="{!extensionMethodThatReturnsAPageReferece}" />

The action attribute specifies a method to be called (in either your controller, or an extension) after the constructor(s) are called, but before the page is rendered. If this method returns a PageReference, the user is then immediately redirected to that PageReference (usually without seeing the blank Visualforce page that preceded it).

If the method that you specify as the action inserts an Attachment, and you return a PageReference to the entry point of DSFS (Page.dsfs__DocuSign_CreateEnvelope), then that should accomplish what you're looking to do here.

Also, because I think you may end up needing it, you may want to download a copy of the DocuSign for Salesforce Administrator's guide. Starting on page 62 (Custom Button Configuration) of that guide is an explanation of all of the parameters that you can pass to DSFS, and what they do.