0
votes

My use case is that a document must be signed by two people : a regular user for which we have an email address, and another user which can be any admin user of my application. The admin user is chosen after the regular user has signed.

My current implementation with the DocuSign API creates an envelope with two signers, the regular user and a second signer called admin-placeholder.

When an admin starts signing, I call the API to replace the admin-placeholder with the actual admin.

Here is my php code (the callDocusign function does what it appears to do) :

// fetch tabs of placeholder user
$tabs= callDocusign($docusignLogin, 'GET', "envelopes/$envelopeId/recipients/$placeholderRecipient/tabs?include_anchor_tab_locations=true");

// remove tabIds to avoid issue on submission
foreach(array_keys($tabs) as $kind) {
    for ($i = 0; $i < count($tabs[$kind]); $i++) {
        // sanitize_user_input removes all properties except those listed in its second argument
        $tabs[$kind][$i] = sanitize_user_input($tabs[$kind][$i], ["documentId", "pageNumber", "xPosition", "yPosition", "anchorString", "anchorXOffset", "anchorYOffset", "anchorIgnoreIfNotPresent", "anchorUnits"]);
    }
}

// add signer
$data = [
    'signers' => [[
        'email' => $user['email'],
        'clientUserId' => pseudo_encrypt($uid),
        'recipientId' => pseudo_encrypt($uid),
        'name' => user_full_name($user),
    ]],
];
callDocusign($docusignLogin, 'POST', "envelopes/$envelopeId/recipients", $data);

// delete placeholder signer
callDocusign($docusignLogin, 'DELETE', "envelopes/$envelopeId/recipients/$placeholderRecipient");

// for some reason setting tabs at signer creation doesn't work
// we'll create them now
callDocusign($docusignLogin, 'POST', "envelopes/$envelopeId/recipients/".pseudo_encrypt($uid).'/tabs', $tabs);

All is working fine but this process ends up duplicating all initialHere tabs of the placeholder user. In my use case the first user has 14 initialHere tabs, and the second signer ends up with 28.

1

1 Answers

1
votes

I'm not sure why you'd get duplicate tabs in the scenario that you've described. However, either of these approaches would likely eliminate that issue:

  • Rather than deleting the placeholder recipient (and tabs) and adding a new recipient (and tabs), simply update the second recipient to specify actual signer info (once it's known, i.e., before you launch the embedded signing session for the second signer).

OR

  • Do things as you are -- except that when you create the placeholder recipient do not specify any tabs for that recipient. Then, when you delete the placeholder recipient, add the new recipient and specify the tabs for that new recipient.