• Asma Salesforce
  • 0 Points
  • Member since 2021

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2

I have installed DocuSign manage package in salesforce and now I want to send DocuSign using apex but along with this, I want to send an email template. Please help me out

EmailTemplate emailTemplate = [Select Id,Subject,Description,HtmlValue,DeveloperName,Body from EmailTemplate where name ='test' limit 1];
Id mySourceId='0032y00000CRaIrAAL';
        //create empty template
         dfsle.Envelope myEnvelope=dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(mySourceId));
        system.debug('myEnvelope::: '+myEnvelope);
        Contact myContact=[Select id,Name,LastName,Email from Contact where id='0032y00000BmZsrAAF'];
        //create reciepient
        dfsle.Recipient myRecipient=dfsle.Recipient.fromSource(
            myContact.Name,//reciepient name
            myContact.Email,//recepient email
            null,//phone number
            'Singer 1',//Role Name Specify the exact role name from template
            new dfsle.Entity(myContact.Id));
         system.debug('myRecipient::: '+myRecipient);
        //add reciepient to the envelope
        myEnvelope=myEnvelope.withRecipients(new List<dfsle.Recipient>{myRecipient});
         system.debug('myEnvelope> '+myRecipient);
        dfsle.UUID myTemplateId=dfsle.UUID.parse('96dcc69d-e5ae-4ebd-a082-be87eb9cab79');
          system.debug('myTemplateId> '+myTemplateId);

        //create a new document for the envelope
        dfsle.Document myDocument=dfsle.Document.fromTemplate(
        myTemplateId,//templateId in dfsle.UUID format
        'test template'  //name of the template
        //add document to the envelope
        system.debug('myDocument> '+myDocument);
        myEnvelope=myEnvelope.withDocuments(new List<dfsle.Document>{myDocument});
        system.debug('myEnvelope===> '+myEnvelope);
        //send the envelope
        myEnvelope,//the envelope to send 
            true//send now ?=true
Please help me.

Button 1 - to refresh the page onclick
Button 2 - to display the success toast message (Which contains record id)
Button 3 - Navigate to www.google.com  (use navigate to URL ) 

public class ApplyDiscount{

public static void insertdiscount(List<opportunity> opplist){
    for(Opportunity oa: opplist){
      if(oa.IsDiscountApplied__c != True)
     { oa.Amount= oa.Amount - oa.Amount*(0.1);