• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Send Echo Document Sign with apex code in saleforce

Guest
Feb 05, 2015 Feb 05, 2015

Copy link to clipboard

Copied

I want to send echo sign document on custom button using apex code.

Document has been send but main issue is that mail not send with proper format, as per standard.

I did not get any link for sign the document.

Please provide me API name by which we can implement this one

My Code is

public class SendAgreementDocument {

    public void SendPdf()

    {

        echosign_dev1__SIGN_Agreement__c agmt = new echosign_dev1__SIGN_Agreement__c();

        agmt.Name = 'Sample Agreement';

        agmt.echosign_dev1__Recipient__c = '003O000000YcB0Q';// Contact field

        agmt.echosign_dev1__Contract__c = '800O00000002sVx';// ContractID;

        agmt.echosign_dev1__Merge_Mapping__c ='a0qO0000006npqT';//Echo Sign  Merge Mapping

        agmt.echosign_dev1__Process_Template__c ='a0kO0000003SdP2';// Echo Sign Data Mapping

        agmt.echosign_dev1__RemindRecipient__c = 'Every Day, Until Signed';

        agmt.echosign_dev1__SenderSigns__c = true;

        agmt.echosign_dev1__Message__c = 'Please sign the attached Insertion Order';

        agmt.echosign_dev1__SignatureType__c = 'e-Signature';

        agmt.echosign_dev1__PasswordProtectSign__c = false;

        agmt.echosign_dev1__SenderSigns__c = true;         

        agmt.echosign_dev1__PasswordProtectPDF__c  = false;

        agmt.echosign_dev1__SignatureOrder__c = 'Recipient signs, then I sign';

        agmt.echosign_dev1__Status__c = 'Draft';

        insert agmt;

        

        System.debug(agmt);

        

        attachment a1 = [select ID, parentId, Name, body, ContentType from Attachment where Id = '00PO0000002LCId'];

        

        Attachment a = a1.clone();

        a.parentId = agmt.id;

        insert a;

       

     

        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();

        attach.setContentType(a.contentType);

        attach.setFileName(a.Name);

        attach.setInline(false);

        attach.Body = a.Body;

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        mail.setUseSignature(false);

        mail.setToAddresses(new String[] {'test@gmail.com' });

        mail.setSubject('Your Statement');

        mail.setHtmlBody('Dear Customer,<br><br> Please find your statement attached in the email.');

       // mail.setFileAttachments(new Messaging.EmailFileAttachment[] {a});

        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });

    

        // Send the email

        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

  

 

       

    }

  

      

  

}

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Mar 04, 2015 Mar 04, 2015

Hi,

If you want to use the EchoSign API directly to send, then you will need to invoke the sendDocumentInteractive API, constructing the SOAP request. Here is the documentation - https://corporate.echosign.com/public/docs/EchoSignDocumentService19?#sendDocumentInteractive

But an easier way is to use the wrapper we provide to send the agreement, make sure you have v15 of our app installed, the latest from the AppExchange, then from your apex code invoke the global echosign_dev1.EchoSignApiService c

...

Votes

Translate

Translate
Guest
Mar 04, 2015 Mar 04, 2015

Copy link to clipboard

Copied

Hi,

If you want to use the EchoSign API directly to send, then you will need to invoke the sendDocumentInteractive API, constructing the SOAP request. Here is the documentation - https://corporate.echosign.com/public/docs/EchoSignDocumentService19?#sendDocumentInteractive

But an easier way is to use the wrapper we provide to send the agreement, make sure you have v15 of our app installed, the latest from the AppExchange, then from your apex code invoke the global echosign_dev1.EchoSignApiService class sendDocument method, passing in the Id of the agreement record which you have created.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

LATEST

To send Agreements using Apex, I have successfully used a blend of Templates and Apex. 
See below for the example.

Template Id: references the template which has the Master Object, Agreements, Merge Mappings already setup.

Lead Id: Id from the Lead record referenced in the template.

 

// Start by generating an agreement Id by loading the template with masterId.

Id agreementId = echosign_dev1.AgreementTemplateService.load('templateId', 'leadId');
// Instantiate an agreement object
echosign_dev1__SIGN_Agreement__c agreement = new echosign_dev1__SIGN_Agreement__c();
// assign the object the Id generated earlier
agreement.Id = agreementId;
// Now you can edit the fields on the object as you wish using apex.
agreement.echosign_dev1__Message__c = 'Hello' + companyName; (In my case, I wanted to personalise the email body using Lead record data).
 // When you have edited all the attributes and changed what is required, its now time to trigger the send from Apex.
// Background Action and Status MUST change in order to send the agreement and stop the agreement from being editable.
agreement.echosign_dev1__Status__c = 'Out for Signature';
agreement.echosign_dev1__Background_Action__c = 'Send';
// DML statement to update the agreement object...
update agreement;
 
FINISHED! Now your agreement will be sent and signed as usual. 
 
If the status is not changing after the agreement has been sent, then navigate to the 'Adobe Acrobat Sign Admin' page, and ensure 'Automatic Updates' is switched on.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines