0

This is my piece of code for building envelope in laravel with docusign API. I am sending documents in envelope dynamically and putting sign here tabs on given anchor string. Here is my code.

private function buildEnvelope($envelopeFiles, $user): EnvelopeDefinition 
{
 $recipientEmail = $user->email; $recipientName = $user->first_name . " " . $user->last_name; 
   
// Create an array to store all CompositeTemplate objects
    $compositeTemplates = [];
    foreach ($envelopeFiles as $index => $documentPath) {
        $fileContent = file_get_contents($documentPath);
        $fileName = pathinfo($documentPath, PATHINFO_BASENAME);
        $fileExtension = pathinfo($documentPath, PATHINFO_EXTENSION);

        // Create a Document object for the current document
        $document = new Document([
            'document_base64' => base64_encode($fileContent),
            'name' => $fileName,
            'file_extension' => $fileExtension,
            'document_id' => $index + 1,
        ]);

        // Create a SignHere tab for the current document on anchor string "Initials"
        $signHereTab = new SignHere([
            'document_id' => $index + 1,
            'page_number' => 1,
            'recipient_id' => '1',
            'anchor_string' => 'Initials',
            'tab_label' => 'Sign Here',
            'anchor_x_offset' => '40',
            'anchor_y_offset' => '0',
            // 'x_position' => '70',
            // 'y_position' => '780'
        ]);

        // Create a Tabs object for the current document with the SignHere tab
        $tabs = new Tabs([
            'sign_here_tabs' => [$signHereTab],
        ]);

        // Create a Signer object for the recipient with the Tabs object
        $recipient = new Signer([
            'email' => $recipientEmail,
            'name' => $recipientName,
            'recipient_id' => '1',
            'routing_order' => '1',
            'tabs' => $tabs,
        ]);

        // Create an InlineTemplate object for the current document with the recipient
        $recipients = new Recipients(['signers' => [$recipient]]);
        $inlineTemplate = new InlineTemplate([
            'sequence' => $index + 1,
            'recipients' => $recipients,
        ]);

        // Create a CompositeTemplate object for the current document with the Document
        $compositeTemplate = new CompositeTemplate([
            'inline_templates' => [$inlineTemplate],
            'document' => $document,
        ]);

        // Add the CompositeTemplate object to the array of CompositeTemplate objects
        $compositeTemplates[] = $compositeTemplate;
    }

    // Create the EnvelopeDefinition object with all the CompositeTemplate objects and other settings
    $envelopeDefinition = new EnvelopeDefinition([
        'composite_templates' => $compositeTemplates,
        'email_subject' => "Please sign the documents",
        'status' => "sent",
    ]);

    return $envelopeDefinition;
}

When I am sending one document, it is working fine but problem arises when I am sending multiple documents. When I am trying to send multiple documents the sign here tabs inserted equal to the number of documents on every anchor string.If I am sending 2 documents for signing then 2 sign here tabs inserted on every anchor string if I am sending 3 documents then 3 sign here tabs inserted and so on. I want only one sign here tab on every anchor string. Can anyone help me in this?

1 Answers1

0

You need to contact DocuSign Customer Support to change the anchor tab scope for your account. That scope controls whether the string is searched over the entire envelope or one single document. You cannot change it yourself, only by contacting support you can change the tab population scope (use this term when you talk to support).

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23