Passing template tabs value while creating envelope

2 min read 06-10-2024
Passing template tabs value while creating envelope


Passing Template Tabs Values When Creating Envelopes in DocuSign

The Problem: You're working with DocuSign and need to create envelopes from templates but want to dynamically populate the template fields with specific values. This is a common requirement when you're automating document signing processes and need to personalize the documents for each recipient.

Simplified Explanation: Imagine sending out a contract to multiple clients. Each contract should have the client's name, address, and specific contract details. DocuSign templates let you create a standardized contract, but you need a way to easily fill in the individual client information for each envelope.

Scenario:

Let's say you have a DocuSign template named "Client Contract" with three tabs:

  • Client Name: Text tab for the client's name.
  • Client Address: Text tab for the client's address.
  • Contract Amount: Number tab for the contract amount.

You need to create multiple envelopes using this template, each with different values for these tabs.

Original Code (Example using Python):

from docusign_esign import EnvelopesApi

# Initialize the API client with your credentials
api_client = EnvelopesApi(api_client)

# Create an envelope definition
envelope_definition = {
    "emailSubject": "Your Client Contract",
    "emailBlurb": "Please review and sign this contract.",
    "status": "sent",
    "templateId": "your_template_id",
    # ... other envelope properties
}

# Create the envelope using the API
envelope_summary = api_client.create_envelope(account_id='your_account_id', envelope_definition=envelope_definition)

# Access the envelope ID for future reference
envelope_id = envelope_summary.envelope_id

Analyzing the Problem:

The above code creates a basic envelope from the template. However, it doesn't specify any values for the template tabs. To populate those tabs with dynamic data, we need to add the templateRoles and tabs parameters within the envelope_definition.

Adding Template Tab Values:

from docusign_esign import EnvelopesApi

# ... Initialize the API client

# Create an envelope definition
envelope_definition = {
    "emailSubject": "Your Client Contract",
    "emailBlurb": "Please review and sign this contract.",
    "status": "sent",
    "templateId": "your_template_id",
    "templateRoles": [
        {
            "roleName": "Client",
            "tabs": {
                "textTabs": [
                    {
                        "tabLabel": "Client Name",
                        "value": "John Doe"  # Dynamically set client name
                    },
                    {
                        "tabLabel": "Client Address",
                        "value": "123 Main Street"  # Dynamically set client address
                    },
                ],
                "numberTabs": [
                    {
                        "tabLabel": "Contract Amount",
                        "value": "1000"  # Dynamically set contract amount
                    }
                ]
            }
        }
    ],
    # ... other envelope properties
}

# Create the envelope using the API
# ...

Explanation:

  1. templateRoles: This parameter defines the roles in the template. Each role corresponds to a signer.
  2. roleName: This specifies the name of the role in the template.
  3. tabs: This contains the tab information that needs to be populated with dynamic data.
  4. textTabs: For text-based tabs like "Client Name" and "Client Address."
  5. numberTabs: For number-based tabs like "Contract Amount."
  6. tabLabel: The label of the tab in the template.
  7. value: The value you want to populate in the tab, which can be dynamically retrieved from your data source.

Benefits:

  • Automation: This approach automates the process of filling out template tabs with dynamic data, significantly improving efficiency.
  • Personalization: Each envelope can be customized with specific information, making it relevant for individual recipients.
  • Error Reduction: Manual data entry is minimized, reducing the risk of errors.

Additional Notes:

  • Replace "your_template_id" with the actual ID of your DocuSign template.
  • The tabLabel should match the labels you defined in your DocuSign template.
  • You can use any programming language that supports DocuSign API integration to implement this solution.

Resources: