I am trying to send the envelopes through the APEX toolkit (Docusign for Salesforce Essentials). Following the documentation from here
Envelope myEnvelope = dfsle.EnvelopeService.sendEnvelope(myEnvelope, true);
When this statement is executed, i am having this error -
common.apex.runtime.impl.ExecutionException: You have uncommitted work pending. Please commit or rollback before calling out
Send Envelope call is doing both the callout and DML updates back to the salesforce record to attach the envelopes
From the documentation provided, there are 3 arguments for the sendEnvelope method which takes Envelope, sendNow flag and updateNow flag. So if i set the 3rd argument to false, that would separate the Callout and DML updates!!
But looks like, sendEnvelope method can only take 2 arguments!
Can anyone help me how to overcome this??
This would occur if you had made any DML operations before calling
sendEnvelope()
within the same transaction. Where a common pattern may be to create/update a record and then send an envelope for it, the solutions would be to callsendEnvelope()
via a @future method or somehow separate the record DML and the callout.