Skip to content

I have written a trigger, But it send Duplicate mail #3

@shuvo955

Description

@shuvo955

`trigger ContractConversion on Contract (before update) {
for(Contract con : trigger.new) {
if(con.Status == '03 - Email to Customer') {
sendEnvelope.sendEnvelopeMethod(con.accountId,con.ContractNumber);

    }
}

}

public class sendEnvelope {

@future(callout=true)
//add comments about source
public static void sendEnvelopeMethod(Id accountId,string ContractNumber) {

	Final String templateGuid = '7635114e-743a-418f-ba6a-1d95a9d51b89';
 	//TemplateId contains the DocuSign Id of the DocuSign Template
	Final dfsle.UUID TemplateId = dfsle.UUID.parse(templateGuid);

	Account account = [SELECT Id FROM Account WHERE Id = :accountId
		LIMIT 1
	];

	// Create an empty envelope with Account Id as the source Id
	dfsle.Envelope envelope = dfsle.EnvelopeService.getEmptyEnvelope(
    	new dfsle.Entity(account.Id));
    
	
	//Find your contact to add
	Contact Contact = [SELECT AccountId, Name, Email FROM Contact
    	WHERE accountId = :accountId
    	LIMIT 1
	];
    
	//use the Recipient.fromSource method to create the Recipient
	dfsle.Recipient Recipient = dfsle.Recipient.fromSource(
    	Contact.Name, // Recipient name
    	Contact.Email, // Recipient email
    	null, //Optional phone number
    	'Customer', //Role Name. Specify the exact role name from template
    	//source object for the Recipient - Account
    	new dfsle.Entity(Contact.Id));
  

	

	//add Recipient to the Envelope
	envelope = envelope.withRecipients (
		new List<dfsle.Recipient> { Recipient });

	//create a new document for the Envelope
	dfsle.Document myDocument = dfsle.Document.fromTemplate(
	TemplateId, // templateId in dfsle.UUID format
	'E-Signature Email Template Contract'); // name of the template

	//add document to the Envelope
	envelope = envelope.withDocuments(
    	new List<dfsle.Document> { myDocument });
    // Send the envelope. 
	envelope = dfsle.EnvelopeService.sendEnvelope(
    	envelope, // The envelope to send
    	true); // Send now parameter not actually part of this method.
}

}

docusign

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions