Docusign Custom Button in Skuid

We just implemented DocuSign and created a few custom buttons based on their template that work great, however, we just realized this On-Click Javascript button will need to be manipulated in Skuid for it to work. I tried following another post on this, but cannot get the DocuSign button to function properly. Any chance someone can point me in the right direction? Any help would be much appreciated.

Here is an example of the template from DocuSign that currently works in Salesforce:

{!REQUIRESCRIPT(“/apex/dsfs__DocuSign_JavaScript”)}var sourceId =DSGetPageIDFromHref();var RQD=DSGetPageIDFromHref();window.location.href = window.location.href = “/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID=”+sourceId+“&RQD=”+RQD;
//********* Option Declarations (Do not modify )//
var RC = ‘’;var RSL=‘’;var RSRO=‘’;var RROS=‘’;var CCRM=‘’;var CCTM=‘’;var CCNM=‘’;var CRCL=‘’; var CRL=‘’;var OCO=‘’;var DST=‘’;var LA=‘’;var CEM=‘’;var CES=‘’;var STB=‘’;var SSB=‘’;var SES=‘’;var SEM=‘’;var SRS=‘’;var SCS =‘’;var RES=‘’;
CRL = ‘Email~{!Independent_Contractors__c.Contact_Email__c};FirstName~{!Independent_Contractors__c.Contact_First_Name__c};LastName~{!Independent_Contractors__c.Contact_Last_Name__c}; Role~Signer 1;RoutingOrder~1’;
CES = ‘Custom Email Subject Here’;
CEM = “Hi {!Independent_Contractors__c.Contact_First_Name__c},\n\nCustom Email Body Here.\n\nThank you,\n\n{!User.Name}\n{!User.Title}\nCompany Name\nStreet\nCity, State ZipCode\nEmail: {!User.Email}\nPhone: {!User.Phone}”;
Page Callout (Do not modify) //
window.location.href =“/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Independent_Contractors__c.Id}&RC=”+RC+“&RSL=”+RSL+“&RSRO=”+RSRO+“&RROS=”+RROS+“&CCRM=”+CCRM+“&CCTM=”+CCTM+“&CRCL=”+CRCL+“&CRL=”+CRL+“&OCO=”+OCO+“&DST=”+DST+“&CCNM=”+CCNM+“&LA=”+LA+“&CEM=”+CEM+“&CES=”+CES+“&SRS=”+SRS+“&STB=”+STB+“&SSB=”+SSB+“&SES=”+SES+“&SEM=”+SEM+“&SRS=”+SRS+“&SCS=”+SCS+“&RES=”+RES;

To recreate the “Send To DocuSign” custom button on a Skuid record detail page:

     1. Add a JavaScript Item
          1a. Resource Location = “External” 
          1b. Resource URL = “/apex/dsfs__DocuSign_JavaScript”
          1c. Resource Name = “DocuSign_JavaScript”
     2. Add a JavaScript Item
          1a. Resource Location = “In-Line (Snippet)” 
          1b. Snippet Name = Send_With_DocuSign
          1c. Snippet Body = 

var params = arguments[0], &nbsp; &nbsp;$ = skuid.$;<br>//********* Option Declarations (Do not modify )*********//&nbsp;<br>var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='1';var SSB='1';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';&nbsp;<br>//*************************************************//&nbsp;<br>var CEM="This is the Email Body.";&nbsp;<br>var CES='This is the Email Subject';&nbsp;<br>var DST = 'This is the DocuSign Template ID';<br>var row = params.row || params.model.getFirstRow();<br>// write row data to console<br>console.log(row);<br>var CRL = 'FirstName~' + row.FirstNameField + ';LastName~' + row.FirstNameField + ';Email~' + row.EmailField + ';Role~Customer;RoutingOrder~1';&nbsp; //********* Page Callout (Do not modify) *********//&nbsp; window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&amp;SourceID=" + row.Id + "&amp;RC="+RC+"&amp;RSL="+RSL+"&amp;RSRO="+RSRO+"&amp;RROS="+RROS+"&amp;CCRM="+CCRM+"&amp;CCTM="+CCTM+"&amp;CRCL="+CRCL+"&amp;CRL="+CRL+"&amp;OCO="+OCO+"&amp;DST="+DST+"&amp;CCNM="+CCNM+"&amp;LA="+LA+"&amp;CEM="+CEM+"&amp;CES="+CES+"&amp;SRS="+SRS+"&amp;STB="+STB+"&amp;SSB="+SSB+"&amp;SES="+SES+"&amp;SEM="+SEM+"&amp;SRS="+SRS+"&amp;SCS="+SCS+"&amp;RES="+RES;

     3. Create Custom Button
          3a. Action Type = “Custom: Run Skuid Snippet”
          3b. Snippet Name = “Send_With_DocuSign”

Thanks for detailing the solution here Chad! 

Thanks Chad! Great outline - this was very helpful.

Rob or Chad - If I wanted to add the current user information to the email body, how would I go about that in the current example?

I tried creating a CurrentUser model and using “getModel” within the the Send_With_DocuSign snippet to no avail.

It seem like the CRL variable construction is affecting the email body. Or there may be another one (I don’t know Docusign’s API well - though I should)

If so,  you could add variables that get user information in Javascript using skuid.utils.userinfo…  (see here:  Then you add the information you ant to the block that starts with “var CRL=…”

Perfect. Thanks Rob.