**Legacy** DocuSign eSignature for Salesforce - URL buttons for Lightning and Mobile - setup / limitations


Salesforce Lightning no longer allows JavaScript buttons for various security reasons, because of this we no longer can use our standard JavaScript custom buttons. Starting in DFS 7.0 we now have a custom button builder which will be a great way to go, however there are currently limitations to that builder that code can solve.


To create a new URL button you can follow the first several steps in the following article, however the add to layout and the below will be the main difference:

User-added image

*The Content Source must be URL, the Behavior selection can be whatever you want, however if you're using mobile the above option is going to be the best option.

Example Code

Example #1:
{!URLFOR('/apex/dsfs__DocuSign_CreateEnvelope', null, [
SourceID = Opportunity.Id,
CCRM = 'Decision Maker~Signer 1',
CCTM = 'Decision Maker~Signer',
DST = 'a2e2cd02-f11e-4c8c-a830-c9f2b6564a9e',
LA = '0',
LF = '0',
OCO = 'Tag'

Here we use the URLFOR format as this will be required from 7.0 and on. With this method we have all parameters contained within an array or comma separated list within the square brackets. We can use all of the same DocuSign parameters that we could with JavaScript. This has some limitations and a few caveats to it:
  • Certain merge fields cannot be used within that array, such as picklist fields, the next method will show how to do that.
  • Merge fields within the URLFOR function (anything within the curly brackets) will just be Object.Field, not the familiar {!Object.Field}, you'll notice in the example above we have 'SourceID = Opportunity.Id'

Example #2:
{!URLFOR('/apex/dsfs__DocuSign_CreateEnvelope', null, [SourceID=Opportunity.Id])}

The difference here is we are adding the parameters outside of the array and outside the URLFOR function (outside the curly brackets) and adding them as query parameters that will be added to the end of the URL to pass these values over to our DFS APEX classes.
  • In this example I had made a picklist for template IDs and this is not supported within the array (Error: Field Opportunity.Template_GUIDS__c is a picklist field. Picklist fields are only supported in certain functions).   
  • Note that now we will use curly brackets around Salesforce fields such as {!Opportunity.Template_GUIDS__c}
  • You'll notice we are just stringing together all parameters, separating them with & and not using any single quotes, those aren't used here outside of URLFOR 
  • Its best practice to put plus signs in place of spaces in parameter values outside of the URLFOR function, though most browsers will do this automatically if we don't.

Example #3: host in person ~ sign now:
{!URLFOR('/apex/dsfs__DocuSign_CreateEnvelope', null, [
SourceID = Opportunity.Id,
DSEID = '0',
CRL = 'Email~' + User.Email + ';FirstName~' + User.FirstName + ';LastName~' + User.LastName + ';SignInPersonName~Signer Name;SignNow~1;RoutingOrder~1;Role~Client1,Email~' + User.Email + ';FirstName~' + User.FirstName +';LastName~' + User.LastName + ';SignInPersonName~Signer Two;SignNow~1;RoutingOrder~2;Role~Client2',
OCO = 'Send',
CCTM = 'Client1~Host in person - sign now;Client2~Host in person - sign now', 
CCRM = 'Client1~Client1;Client2~Client2',
LF = 1

This is a fairly common use case where the customer wants to be able to click a button and start the in person signing right there in their browser or on the mobile app.
  • The important aspects here are the CRL and CCTM since in order to make 'sign now' work we need to ensure that we are using the current Salesforce user's exact name and email, hence why we use fields like User.Email. For CCTM roles must be mapped to this exactly: 'Host in person - sign now'
  • This button works on the Salesforce mobile app in at least version 7.0 and higher, however due to some limitations with the mobile app we need to bypass the Visualforce page and the tagger, which is why we have OCO = 'Send'. The Visualforce page on mobile is very limited in functionality and will ignore custom settings and parameters. The tagger on mobile also does not optimize nicely to mobile so its recommended just to make the workflow work as a one click option send to bypass all of those, this of course recipients need to be automatically added, tags need to be autoplaced or added using a template, and everything else needs to be done using the button code.
  • The host of the host in person will need to ensure that their Salesforce email matches their DocuSign email, otherwise we can't go straight to the 'sign now' and will instead require them to start the signing via their email.
  • Starting in version 7.0.1 we will have a setting in the DocuSign Admin object to allow sequential in person signing so this multiple signers situation can work all from the SF mobile app or a browser without leaving Salesforce.

Add to Layout for Mobile and Lightning use

The button will actually be added to a different layouts section than Classic buttons, see how to get to the edit layouts page in both Classic and Lightning and from there how to add buttons.

In Classic Salesforce:
From the object you're adding the button to, go to any record and select 'edit layout':
User-added image

In Lightning Salesforce:
User-added image


Add to Layouts page in Classic and Lightning

From a record click the gear or setup icon in the upper right corner of the page > select 'Edit Object' > select 'Page Layouts' > select the layout you want to update > this should bring you to the same edit layout page you see in Classic.

User-added image
  1. Click 'Mobile & Lightning Actions'
  2. Find your new URL button
  3. Scroll to the 'Salesforce Mobile and Lightning Experience Actions' section
  4. Drag and drop the button to to the 'Salesforce Mobile and Lightning Experience Actions' section
  5. Click 'Save' and return to your Salesforce record 

Known Limitations

  • Cannot use JavaScript logic such as if-else statements or for-loops or use declared variables, these need to be done outside of the button code for instance in a formula field on the record or via a custom component or trigger.

Learn More

  • Custom button configuration guide