Search code examples
docusignapi

When creating a docusign envelope from more than 2 templates I get an API error TAB_PAGENUMBER_IS_NOT_IN_DOCUMENT


I set up some templates in the account through the UI and let docusign create the tabs from the PDF form fields. So I did not create any tabs in the documents through the API.

When I try to use the API to create an envelope from these templates I get an error: TAB_PAGENUMBER_IS_NOT_IN_DOCUMENT (The pagenumber specified in the tab element is not in the document). I tried a process of elimination to see if it was a specific template that is the issue but it appears the error goes away if I remove any 2 of the 4 templates. I can use the first 2 or the last 2 and it works, but I cannot use 3 or 4 of the templates.

Here is the JSON data I am submitting to create the envelope:

{
    "emailSubject": "Please sign your application documents",
    "compositeTemplates": [
        {
            "serverTemplates": [
                {
                    "sequence": 1,
                    "templateId": "7701a466-519b-4729-bc90-8823a29c8474"
                },
                {
                    "sequence": 1,
                    "templateId": "68482978-dcfd-42df-b19b-b95d2198dc9a"
                },
                {
                    "sequence": 1,
                    "templateId": "640e044d-85cc-41b8-bf3d-018715a2df71"
                },
                {
                    "sequence": 1,
                    "templateId": "99fbb00a-edca-4cd7-acd6-715162b3a67b"
                }
            ]
        }
    ]
}

Solution

  • Pre-Operations: You say you created the four templates by providing a PDF with form fields and letting DocuSign transform the fields to DocuSign tabs. Since it wouldn't make sense to use the same form to create four templates, I'm assuming you used different PDFs for each template.

    Composites: In your envelope create call, you only specified a single compositeTemplate with only an array of serverTemplates. This means only the first template processed will contribute a document to the envelope.

    Sequence of templates: You specified a sequence of "1" for each template in the array. This means they will be processed in the order received, i.e. the array order.

    Processing: The first template in the array will contribute the document, roles w/ routing order, and tabs for each role. Each subsequent template will add any additional roles w/ routing order and their associated tabs.

    Observed outcome: If the first template has n pages, and any of the subsequent templates have >n pages that also contribute tabs on pages >n, then you will be attempting to add tabs on pages that don't exist.

    Desired outcome: I'm wondering if you meant to create an envelope with 4 documents and tabs for those documents? If so, you want FOUR composite templates, each having a serverTemplate array with only a single template.

        {
        "emailSubject": "Please sign your application documents",
        "compositeTemplates": [
            {
                "serverTemplates": [
                    {
                        "sequence": 1,
                        "templateId": "7701a466-519b-4729-bc90-8823a29c8474"
                    }
                ]
            },
            {
                "serverTempates": [
                    {
                        "sequence": 1,
                        "templateId": "68482978-dcfd-42df-b19b-b95d2198dc9a"
                    }
                ]
            },
            {
                "serverTemplates": [
                    {
                        "sequence": 1,
                        "templateId": "640e044d-85cc-41b8-bf3d-018715a2df71"
                    }
                ]
            },
            {
                "serverTemplates": [
                    {
                        "sequence": 1,
                        "templateId": "99fbb00a-edca-4cd7-acd6-715162b3a67b"
                    }
                ]
            }
        ]
    }
    

    Note that you will also want to have an inlineTempate for each composite to map a recipient to each desired template role, unless your templates have hard-coded recipients.