Guides

Create Embedded Unclaimed Draft With Template

Creates a new draft with a previously saved template that can be claimed and used in an embedded iFrame

📘

The first authenticated user to access the URL will claim the Draft and will be shown the "Request signature" page with the Draft loaded. Subsequent access to the claim URL will result in a 404. For this embedded endpoint the requester_email_address parameter is required.

🚧

Embedded unclaimed drafts can only be accessed in embedded iFrames whereas normal drafts can be used and accessed on HelloSign. Please see How to Open an Embedded Claim URL for more info.

Class: HelloSign.SignatureRequestService

Return type: HelloSign.ServiceObjects.UnclaimedDraftResponse

Method

Name
createEmbeddedUnclaimedDraftWithTemplate()

Acceptable Parameters

NameTypeRequiredNote
originObjectIdIdSet this if you want your HelloSignSignature_Request_c record to populate the RelatedObject_Id_c field. We will also attempt to populate the lookup field, Account__c for example if the Id is a Supported Object
template_idStringHelloSign_TemplateUUID_c field from the HelloSign_Template_c object.
requester_email_addressString
test_modeBooleanThe signature request will not be legally binding when set to true.
titleStringThe title you want to assign to the SignatureRequest.
subjectStringThe subject in the email that will be sent to the signers.
messageStringThe custom message in the email that will be sent to the signers.
signersMap<String, HelloSign.ServiceObjects.Signer>The list of recipients who will be required to sign.
ccsMap<String, HelloSign.ServiceObjects.CC>List of recipients who will receive a copy only.
signing_redirect_urlStringThe URL you want the signer redirected to after they successfully sign.
requesting_redirect_urlStringThe URL you want signers redirected to after they successfully request a signature.
custom_fieldsList<HelloSign.ServiceObjects.CustomField>Editable custom_fields are only supported for single signer requests or the first signer of ordered signature requests. If more than one signer is assigned to the unordered signature request, any editor value is ignored and the field will not be editable.
fileIdsList<Id>Accepted Id types are ContentDocument, Attachment, or Document.

Setting this will append additional files to the signature request.

Cannot use file_url when this is set.
file_urlList<String>Cannot use fileIds when this is set
skip_me_nowBooleanDisables the "Me (Now)" option for the person preparing the document. Does not work with type "send_document".
allow_declineBooleanAllows signers to decline to sign a document.
allow_reassignBooleanAllows signers to reassign their signature requests to other signers.
hold_requestBooleanThe request from this draft will not automatically send to signers post-claim.
signing_optionsHelloSign.ServiceObjects.SigningOptionsIf signing_options are not defined in the request, the allowed types will default to those specified in the account settings.
field_optionsHelloSign.ServiceObjects.FieldOptionsThis allows the requester to specify field options for a signature request.
isLastCalloutBoolean
HelloSign.SignatureRequestService sigReq = new HelloSign.SignatureRequestService();

/**
 * Required Params
 */
sigReq.requester_email_address = '[email protected]';

Id sfdcTemplateId = 'a091g00000APasjAAD';
// Use the HelloSign__TemplateUUID__c to set our template_id
sigReq.template_id = [SELECT HelloSign__TemplateUUID__c FROM HelloSign__Template__c Where Id = :sfdcTemplateId].HelloSign__TemplateUUID__c;

List<HelloSign__SignerRole__c> signerList = [
    SELECT HelloSign__Role_Name__c,
        HelloSign__SpecificContact__r.Name, HelloSign__SpecificContact__r.Email,
        HelloSign__SpecificUser__r.Name, HelloSign__SpecificUser__r.Email,
        HelloSign__SpecificEmail__c, HelloSign__SpecificFirstName__c
    FROM HelloSign__SignerRole__c
    WHERE
        HelloSign__Template__c = :sfdcTemplateId
        and HelloSign__IsCcRole__c = false];

sigReq.signers = new Map<String, HelloSign.ServiceObjects.Signer>();

for (HelloSign__SignerRole__c rec : signerList) {
    HelloSign.ServiceObjects.Signer signerObj;

    // Note: If no value is populated in the lookup, HelloSign__SpecificContact__c, for example
    // then you need to provide your own value
    if (rec.HelloSign__Role_Name__c.startsWith('Contact')) {
        signerObj = new HelloSign.ServiceObjects.Signer(
            rec.HelloSign__SpecificContact__r.Email,
            rec.HelloSign__SpecificContact__r.Name);

    } else if (rec.HelloSign__Role_Name__c.startsWith('User')) {
        signerObj = new HelloSign.ServiceObjects.Signer(
            rec.HelloSign__SpecificUser__r.Email,
            rec.HelloSign__SpecificUser__r.Name);

    } else {
        signerObj = new HelloSign.ServiceObjects.Signer(
            rec.HelloSign__SpecificEmail__c,
            rec.HelloSign__SpecificFirstName__c);
    }

    // Adding signers for our request is role based, which is why we put the Role Name as our key
    sigReq.signers.put(rec.HelloSign__Role_Name__c, signerObj);
}

/**
 * Optional Params
 */
sigReq.test_mode = true;
sigReq.originObjectId = '001f200001cFD4x';
sigReq.title = 'My first signature request';
sigReq.subject = 'Testing this signature request';
sigReq.message = 'Hello, please sign the following document. Thank you';
sigReq.signing_redirect_url = 'https://hellosign.com';
sigReq.requesting_redirect_url = 'https://hellosign.com';
sigReq.skip_me_now = true;
sigReq.allow_decline = true;
sigReq.allow_reassign = true;

sigReq.ccs = new Map<String, HelloSign.ServiceObjects.CC>();

// SOQL would be the same as line 12 except we would check if HelloSign__IsCcRole__c = true
List<HelloSign__SignerRole__c> ccList;

for (HelloSign__SignerRole__c rec : ccList) {
    String ccEmail;

    // Note: If no value is populated in the lookup, HelloSign__SpecificContact__c, for example
    // then you need to provide your own value
    if (rec.HelloSign__Role_Name__c.startsWith('Contact')) {
        ccEmail = rec.HelloSign__SpecificContact__r.Email;

    } else if (rec.HelloSign__Role_Name__c.startsWith('User')) {
        ccEmail = rec.HelloSign__SpecificUser__r.Email;

    } else {
        ccEmail = rec.HelloSign__SpecificEmail__c;
    }
    sigReq.ccs.put(rec.HelloSign__Role_Name__c, new HelloSign.ServiceObjects.CC(ccEmail));
}

// Append additional file to the signature request
ContentVersion cvRec = [SELECT ContentDocumentId FROM ContentVersion WHERE Title = 'myFile.pdf' LIMIT 1];
sigReq.fileIds = new List<Id>{ cvRec.ContentDocumentId };

// Specify which signing options are allowed for the signer
sigReq.signing_options = new HelloSign.ServiceObjects.SigningOptions();
sigReq.signing_options.draw = false;
sigReq.signing_options.phone = false;
sigReq.signing_options.type_x = true;
sigReq.signing_options.upload = false;
sigReq.signing_options.default_x = 'type';

sigReq.field_options = new HelloSign.ServiceObjects.FieldOptions();
sigReq.field_options.date_format = 'YYYY / MM / DD';

// Send the request
HelloSign.ServiceObjects.UnclaimedDraftResponse response = sigReq.createEmbeddedUnclaimedDraftWithTemplate();

// Object type: HelloSign.ServiceObjects.UnclaimedDraft
System.debug(response.unclaimed_draft);

// Object type: List<HelloSign.ServiceObjects.Warning>
System.debug(response.warnings);