I am trying to send my opportunity record for docusign signature through apex, I would like to add some customised apex logic for which i need envelope template id, but its not populating under the object "Docusign Envelope" the value is null, but when i send for signature through the docusign created button the field is populated. Not sure what I am doing wrong here. Below is the apex code:
mySourceId = '006S000000OARxxxxx'; // The ID of the initiating Salesforce object
String templateId ='xxxxxxxx-xxxx-xxxx-xxxx-ba3e7fe374a2'; // The ID of the DocuSign template
// Create an empty envelope
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
new dfsle.Entity(mySourceId));
// The initiating Salesforce entity
// Use myEnvelope for later
// We will use a Salesforce contact record as a Recipient here
opportunity oppo = [select id,ownerid,owner.Name,owner.email,email_Custom__c,Name__Custom__cfrom opportunity where id =: mySourceId ];
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
oppo.Name__Custom__c, // Recipient name
oppo.email_Custom__c, // Recipient email
null, // Optional phone number
'Signer 1', // Role Name. Specify the exact role name from template
new dfsle.Entity(oppo.Id)); // Source object for the recipient
dfsle.Recipient myRecipient1 = dfsle.Recipient.fromSource(
oppo.owner.name, // Recipient name
oppo.owner.email, // Recipient email
null, // Optional phone number
'Signer 2', // Role Name. Specify the exact role name from template
new dfsle.Entity(oppo.Id));
// Add a recipient to the envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient,myRecipient1 });
// myTemplateId contains the DocuSign Id of the DocuSign Template
dfsle.UUID myTemplateId = dfsle.UUID.parse(templateId);
// create a new document for the Envelope
dfsle.Document myDocument = dfsle.Document.fromTemplate(
myTemplateId, // Template Id in dfsle.UUID format
'EVSE Site Agreement Template1'); // Name of the template
//add document to the envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
// Send the envelope
myEnvelope = dfsle.EnvelopeService.sendEnvelope(
myEnvelope, // The envelope to send
true); // True to send the envelope now
I tried creating new template and still the field didn't get populated.