docusignapidocusign-sdk

How to fill values in a document in DocuSign API?


Basically I am uploading a document which has pdf fields already (using Adobe acrobat), and I want to pre-fill a field with value as "John" while sending it but it is unable to set any value. I am recieving the pdf and it has indeed detected all the fields but no value has been filled. What am I doing wrong?

{
  "documents": [{
    "documentId": 101,
    "documentBase64": "{{document}}",
    "name": "new",
    "fileExtension": "pdf",
    "transformPdfFields": true
  }],
  "emailSubject": "Test Sign",
  "recipients": {
    "signers": [{
      "email": "myself@gmail.com",
      "name": "Abhay",
      "recipientId": 1,
      "tabs": {
        "textTabs": [
          {
            "tabLabel": "dealer_name",
            "value": "John"
          }]
        }
    }]
  },
  "status": "sent"
}

Solution: Composite Templates are the way to go as suggested by Larry K:

{
  "compositeTemplates": [
    {
      "compositeTemplateId": "1",
      "document": {
        "documentBase64": "{{document}}",
        "transformPdfFields": "true",
        "documentId": "1",
        "fileExtension": "pdf",
        "name": "Example Agreement"
      },
      "inlineTemplates": [
        {
          "recipients": {
            "signers": [
              {
                "email": "youremail@gmail.com",
                "name": "Abhay",
                "recipientId": "1",
                "defaultRecipient": "true",
                "tabs": {
                  "textTabs": [
                    {
                      "tabLabel": "dealer_name",
                      "value": "Zack Customer",
                      "locked": "true"
                    }
                  ]
                }
              },
            ]
          },
          "sequence": "1"
        }
      ]
    }
  ],
  "emailSubject": "Testing Transform PDF Fields",
  "status": "sent"
}

Solution

  • I believe that you need to use the Composite Templates pattern since you want to change (the value) of a field after it was created (transformed) from the PDF form field.

    This blog post has the details.

    Also, after you send the envelope, whether it works or not, use Envelopes:get to see the tabs that were added by the PDF transform. That will show you the details on the tabs that were created from the PDF form.

    Here's a tool that will show you the Envelopes:get response.

    // API call for Envelopes:get:
    let apiMethod = `/accounts/${accountId}/envelopes/${envelopeId}?
    include=recipients,documents,custom_fields,folders,tabs"`;