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

Example 3: Send signature request with dynamic merge data

This example demonstrates sending a dynamic Signature Request using HelloSign Text Tags and Custom Fields.

🚧

CALLOUT

Writeback into Salesforce from editable Text Tags is not currently supported.

// Specify a parent record and signer. See Example 1 above for more details. 
Id parentId = '001f200001cFD4x';

HelloSign.HelloSignDocumentService.Signer signer = 
    new HelloSign.HelloSignDocumentService.Signer();
signer.name = 'Signer Name';
signer.email = '[email protected]';

// Specify a document that has merge Text Tags. (See examples in the comments below.)
HelloSign.HelloSignDocumentService.Document doc = 
    new HelloSign.HelloSignDocumentService.Document();
doc.recordId = '069f2000005M1lp';
List<HelloSign.HelloSignDocumentService.Document> docs = 
    new List<HelloSign.HelloSignDocumentService.Document>{doc};

// Set up the Signature Request service object like in the above examples
HelloSign.HelloSignDocumentService.SignatureRequest sigReq = 
    New HelloSign.HelloSignDocumentService.SignatureRequest();
sigReq.subject = 'Sending with Custom Fields';
sigReq.message = 'Please sign the agreement';
sigReq.signers = new List<HelloSign.HelloSignDocumentService.Signer>{signer};

// Add two custom fields to correlate with the two Text Tags in the attached document. The values are hard-coded here, but could be dynamically populated.
// [text-merge|req|sender|company_name]
sigReq.customFields.add(new HelloSign.HelloSignDocumentService.CustomField());
sigReq.customFields[0].name = 'company_name';
sigReq.customFields[0].value = 'Acme Co.';

// [text-merge|req|sender|phone]
sigReq.customFields.add(new HelloSign.HelloSignDocumentService.CustomField());
sigReq.customFields[1].name = 'phone';
sigReq.customFields[1].value = '415-555-1212';

// Send the signature request
HelloSign.HelloSignDocumentService.SendSignatureResponse response = 
    HelloSign.HelloSignDocumentService.sendSignature(parentId, docs, sigReq);