Guides
These docs are for v4.6. Click to read the latest docs for v4.29.

Example 1: Send signature request using Text Tags

This example shows sending a signature request from an Account using a document with embedded HelloSign Text Tags to two signers signing in parallel.

See Example 3 to merge Salesforce data using Text Tags.

Compatibility

Copy the text in the box into a word document and convert the document to a PDF. Both signers will see signature and date text tags as well as an optional note field.

Signature One:

   

[sig|req|signer1]

Date:

[date|req|signer1]

Signature Two:

   

[sig|req|signer2]

Date:

[date|req|signer2]

/**
 * Specify a parent record for the signature request. The record must be of a 
 * supported object type (eg. Account, Contact, Lead, Opportunity, or any 
 * objects set up in the HelloSign Settings Supported Object section). The 
 * completed signature request document will be attached to this record.
 */
Account acct = [SELECT Id FROM Account WHERE Name = 'Test Account' LIMIT 1];


/**
 * Specify the document for the signature request. Supported objects are 
 * Salesforce Files (ContentDocument), Attachments, or Documents. The PDF 
 * in this example is at https://app.hellosign.com/docs/texttags_example.pdf.
 */
// Use for Salesforce Files
Id docId = [SELECT ContentDocumentId FROM ContentDocumentLink
            WHERE LinkedEntityId = :acct.Id AND 
                  ContentDocument.Title = 'MyPDF' LIMIT 1].ContentDocumentId;

// Use for Salesforce Attachments
// Id docId = [SELECT Id FROM Attachment WHERE Name = 'MyPDF.pdf' LIMIT 1].Id;

// Use for Salesforce Documents
// Id docId = [SELECT Id FROM Document WHERE Name = 'MyPDF.pdf' LIMIT 1].Id;

// Specify signers for the signature request, in this case two Contacts.
Contact signer1 = [SELECT Id, Name, Email FROM Contact
                   WHERE AccountId = :acct.Id AND Name = 'Signer 1'];

Contact signer2 = [SELECT Id, Name, Email FROM Contact
                   WHERE AccountId = :acct.Id AND Name = 'Signer 2'];

// Set up the HelloSign.HelloSignDocumentService.SignatureRequest object
HelloSign.HelloSignDocumentService.SignatureRequest sigReq =
   new HelloSign.HelloSignDocumentService.SignatureRequest();



// Specify additional parameters (see Resource Table below)
sigReq.title = 'Warranty Agreement';
sigReq.subject = 'Please sign the warranty agreement';
sigReq.message = 'Hello, please sign the agreement. Thank you.';

/**
 * If your document doesn't use HelloSign Text Tags, then set useTextTags to 
 * false. See http://app.hellosign.com/api/textTagsWalkthrough for more info. 
 */
// sigReq.useTextTags = false;


// Set up your signers from the Contact records
sigReq.signers.add(new HelloSign.HelloSignDocumentService.Signer());
sigReq.signers[0].name = signer1.Name;
sigReq.signers[0].email = signer1.Email;


sigReq.signers.add(new HelloSign.HelloSignDocumentService.Signer());
sigReq.signers[1].name = signer2.Name;
sigReq.signers[1].email = signer2.Email;

// Set up the HelloSign.HelloSignDocumentService.Document list
List<HelloSign.HelloSignDocumentService.Document> documents =
   new List<HelloSign.HelloSignDocumentService.Document>();
documents.add(new HelloSign.HelloSignDocumentService.Document());
documents[0].recordId = docId;

// Send the signature request with parent record ID and service objects
HelloSign.HelloSignDocumentService.SendSignatureResponse response =
   HelloSign.HelloSignDocumentService.sendSignature(acct.Id, Documents, sigReq);