DocuSign for Salesforce - "Too many DML statements" error when attempting to Send with DocuSign

Issue

Error occurs when attempting to use Send with DocuSign button on some records in Salesforce.  

dsfs: Too many DML statements: 151

Error is in expression '{!CreateEnvelopeRecord}' in component <apex:page> in page dsfs:docusign_createenvelope: (dsfs)

Cause

Error can be caused when the Send with DocuSign button is trying to pull in too many associated attachments.

Solution

Because the standard Send with DocuSign button pulls in all attachments from a record, a Salesforce administrator will need to create custom button that ignores attachments.

If you already have a custom button set up, the following value can be set to ignore attachments: LA='0';

The process to create the custom button itself is documented here: How to Create a Salesforce Custom Button

When creating the new custom button, use the following code:

 
{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}

//********* 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='';

//*************************************************//

//Toggle load attachments

LA = '0'; // 0 = off, 1 = on

//********* Page Callout (Do not modify) *********//

window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.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;

//*******************************************//
 

Once the button has been created, you will need to add it to the appropriate layout.

When sending from records that encounter this error, the new custom button must be used.

If your organization's workflow does not rely on automatically pulling in attachments when using the Send with DocuSign button, you may consider hiding the standard button so only the button that does not load attachments is visible.

If using this button does not resolve the DML statement error, please contact support.