Skip to content

Instantly share code, notes, and snippets.

@ptronina
Last active February 7, 2021 19:26
Show Gist options
  • Save ptronina/7af71c20bc211ea87e9d4bf71618db71 to your computer and use it in GitHub Desktop.
Save ptronina/7af71c20bc211ea87e9d4bf71618db71 to your computer and use it in GitHub Desktop.
ApexToolkitCustomEnvelope
public class ApexToolkitCustomEnvelope {
public static void sendEnvelopeMethod(Id mySourceId){
// The ID of the initiating Salesforce object.
// Create an empty envelope.
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
new dfsle.Entity(mySourceId));
// The initiating Salesforce entity.
//we will use a Salesforce contact record as a Recipient here
Contact myContact = [SELECT Id, Name, Email FROM Contact LIMIT 1];
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
myContact.Name, // Recipient name
myContact.Email, // Recipient email
null, //Optional phone number
'Signer 1', //Role Name. Specify the exact role name from template
new dfsle.Entity(myContact.Id)); //source object for the Recipient
//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });
//use the Envelope withEmailadd method to add Subject and Message your Envelope
myEnvelope = myEnvelope.withEmail('Sample Subject', 'Sample message');
// Send the envelope.
myEnvelope = dfsle.EnvelopeService.sendEnvelope(
myEnvelope, // The envelope to send
true); // Send now?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment