Suzanne
Suzanne

Reputation: 754

DocuSign API: custom fields populating

I'm confused about the difference between "tabs" and "custom fields," perhaps --

When I send a json to DocuSign API's baseURL/envelopes, asking the API to send an envelope with a template, it works fine:

{ "accountId": "xxx",
   "status": "sent",
   "emailSubject": "Please sign this document",
   "emailBlurb": "Here's a document for you to sign",
   "templateId": "xxxx",
   "templateRoles": [
        {
            "email": "[email protected]",
            "name": "Test Person",
            "roleName": "parent_signer" }] }

When I try to add parameters for custom field filling, I get a 400 error:

{ "accountId": "xxx",
   "status": "sent",
   "emailSubject": "Please sign this document",
   "emailBlurb": "Here's a document for you to sign",
   "templateId": "xxxx",
   "templateRoles": [
        {
            "email": "[email protected]",
            "name": "Test Person",
            "tabs": [
               { "textTabs":
                  [
                     {"tabLabel": "Doc_Name",
                      "name": "Doc_Name",
                      "value": "Doc Name Data Would Go Here"}
                  ]
               }
            ],
            "roleName": "parent_signer" }] }

And the single document in my template in question has custom fields with those names. https://i.sstatic.net/FF6F0.jpg

Upvotes: 1

Views: 3206

Answers (2)

Stephen Thomas-Dorin
Stephen Thomas-Dorin

Reputation: 11

"tabs" is not an array. There is a docusign exmaple here: https://developers.docusign.com/esign-rest-api/guides/features/templates

You're code should look like this:

    ...
    "templateRoles": [             // is an array
        {
            "email": "[email protected]",
            "name": "Test Person",
            "tabs": {              // is not an array (an object)
                "textTabs": [      // is an array (of objects)
                    {
                        "tabLabel": "Doc_Name", // should match Template "Data Label"
                        "name": "Doc_Name", // this field is unnecessary
                        "value": "Doc Name Data Would Go Here"
                    }
                ] // , other arrays of tabs like checkboxTabs may go here as well
            }
            "roleName": "parent_signer" }] }

Upvotes: 1

Frederic
Frederic

Reputation: 2065

You need to specify the document and page in which the tab needs to be displayed. In JSON, it would look like below :

"textTabs": [
    {
        "tabLabel": "Doc_Name",
        "name": "Doc_Name",
        "value": "Doc Name Data Would Go Here",
        "DocumentId": "123",
        "PageNumber": "1"
    }

Upvotes: 1

Related Questions