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.