**Legacy** DocuSign eSignature for Salesforce - Debug Button for SourceID

This issue pertains to DocuSign eSignature for Salesforce version 6.9.4 and older. Versions 7.0 and newer do not utilize Javascript. 


DocuSign eSignature for Salesforce custom button error: "The SourceID value for this DocuSign Custom Button is invalid".


The SourceID variable is fundamental to the send and write-back functionality of DocuSign eSignature for Salesforce. It stores the Salesforce identity of the object the envelope is being sent from. There are many reasons this error would occur. Most often this error is due to Salesforce permission restrictions imposed on a specific command being used that would fall outside the scope of Customer Support. The goal of this article is to provide an efficient method of identifying which commands are functional in the Salesforce environment.

The code below is an expansion of the basic JavaScript custom button framework used in our documentation. It includes comments that explain its purpose and multiple commands for testing. Use of this code is at the discretion of the Salesforce administrator with the understanding of its purpose as a simple diagnostic tool.

Note: Development efforts and further code expansion remain outside the scope of DocuSign Customer Support.

Diagnostic DocuSign eSignature for Salesforce Custom Button Code

// Below are four methods for calling the record ID of the location
// of a custom button. Some may fail depending on the environment configuration.
// Also keep in mind that in some cases identities will have to be
// modified based on the type of Object the button is associated with.

// Example: Opportunity.Id for Opportunities, Account.Id for Accounts,
// Case.Id for Cases, etc. You can use the double forwardslash method above
// to comment out any method that may be causing you an error once
// they have been identified.

// Clicking the button should pop up with an alert for the start of
// each test, run the command, and return either an error or the resulting
// value. After the four tests are complete, whatever attributes set
// in the bottom section will create a Visualforce sending draft.

var SourceID1 = '';
var SourceID2 = '';
var SourceID3 = '';
var SourceID4 = '';

alert('test one begins');
SourceID1 = window.sfdcPage.entityId;
alert('This is the value of window.sfdcPage.entityId: '+SourceID1);

alert('test two begins');
SourceID2 = window.sfdcPage.getEntityId();
alert('This is the value of window.sfdcPage.getEntityId(): '+SourceID2);

alert('test three begins');
SourceID3 = '{!Opportunity.Id}';
alert('This is the value of !Opportunity.Id: '+SourceID3);

alert('test four begins');
SourceID4 = DSGetPageIDFromHref(); 
alert('This is the value of DSGetPageIDFromHref(): '+SourceID4); 

//********* THIS IS THE ACTUAL BUTTON CODE ***********************//

//********* Recommend Not Modifying Variable Declaration *********//
var sourceId = window.sfdcPage.getEntityId();
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='';

// framework variables pasted above
// any modification chosen posted between to define variables
// a URL is built below to actually execute the command in Salesforce 

//********* Recommend Not Modifying Page Callout *********//
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID="+sourceId+"&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;