StevenDStanton
StevenDStanton

Reputation: 866

Docusign Customer Document Data

With docusign is there a way to send custom data to the document.

The use-case we have is that we are having customers sign an embedded form. We populate all of their data from our Database.

So the main contract is the same but we need to send some values such as contract number, name, address, and price to the document we are having signed. What would be the best way to accomplish this?

I have seen customer tags mentioned for this purpose but it seems like we can only do this in classic view which makes it seem like this will not be a supported feature in the new version.


Update:

I am still at a stand still on this issue.

I have tried doing what was suggested and setting textCustomFields

However, no matter what I pass in the label I set up does not show up.

For example.

I have the Name field on my Document and I also have a Text Field with the Data Label of: contractid

Then I try passing the data in in my envelope as described in the documentation (I have yet to find an example of this anywhere)

string requestBody = 
                "<envelopeDefinition  xmlns=\"http://www.docusign.com/restapi\">" +
                "<status>sent</status>" + 
                "<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
                "<templateId>" + templateId + "</templateId>" + 
                "<templateRoles>" + 
                "<templateRole>" + 
                "<email>" + recipientEmail + "</email>" +   
                "<name>" + recipientName + "</name>" +
                "<roleName>" + templateRole + "</roleName>" + 
                "<clientUserId>1</clientUserId>" +  // user-configurable
                "</templateRole>" + 
                "</templateRoles>" + 
                "<customFields>" +
                "<textCustomFields>" +
                "<fieldId>contractid</fieldId>" +
                "<name>contractid</name>" +
                "<required>true</required>" +
                "<show>true</show>" +
                "<value>123</value>" +
                "</textCustomFields>" +
                "</customFields>" +
                "</envelopeDefinition>";

The name field shows up correctly in the contract, but that is a custom field predefined by Docusign

However, the contractid field just shows blank as no data has been passed into it.

I even tried adding the information into the call to my view for when I show the embeded contract and that does not do anything either.

I may be going about this the wrong way but so far I can find no good documentation on how to send custom data into the contract via the REST API.

Edit:

Here is a Screen Shot of my setup and I have attempted to add the Text Tabs into both the envelope and the document view request.

I have to say I have worked with Multiple Rest API's including working with Twilio, Phaxio, Twitter and this Rest API implementation seems to be the most confusing I have every ran across as far as what does what

enter image description here

Upvotes: 4

Views: 915

Answers (3)

StevenDStanton
StevenDStanton

Reputation: 866

For those using XML and trying to auto fill in the data

string requestBody = 
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" + 
"<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
"<templateId>" + templateId + "</templateId>" + 
"<templateRoles>" + 
"<templateRole>" + 
"<email>" + recipientEmail + "</email>" +   
"<name>" + recipientName + "</name>" +
"<roleName>" + templateRole + "</roleName>" + 
"<clientUserId>1</clientUserId>" +  // user-configurable
"<tabs>" + 
"<textTabs>" + 
"<text>" + 
"<anchorString>follows:</anchorString>" +
"<value>Initial Data Goes</value>" + 
"</text>" + 
"</textTabs>" + 
"</tabs>" + 
"</templateRole>" + 
"</templateRoles>" + 
"</envelopeDefinition>";

Then anywhere in your document you have the words follows: you will have the text show up and you can modify it to display it where you want using other fields.

Upvotes: 0

Dan Loughney
Dan Loughney

Reputation: 4677

We are working through our DocuSign implementation and are able to do what you are looking for with textTabs added to the signers object. I've attached my POC code in PowerShell that shows the tabs being formatted.

We generate contracts in Word 2013 and use anchors to place everything. The source document will have something like //SIGNATURE// in the text, but before release it is highlighted and changed to white font so the final contract renders nicely in DocuSign.

enter image description here

Results in this (except I chopped out the name and title) enter image description here

Put your API Key and credentials into the logon function and set up the recipient info at the top. The script creates and sends an envelope with document called "contract.docx"

[string]$recipientEmail = "[email protected]"
[string]$recipientName = "Mr. Mann"
[string]$recipientFirstName = "Mann"
[string]$recipientTitle = "CEO, Mann, Inc."

function boundry {
    [System.Guid]::NewGuid().ToString()
}

function encodeFile {
    param ([string]$fileName)
    [System.Convert]::ToBase64String([IO.File]::ReadAllBytes((Resolve-Path $fileName).ProviderPath))
}


function logonParams {
    [string] $userName = 'YOUR USER NAME' 
    [string] $password = 'YOUR PASSWORD'
    [string] $integratorKey = 'YOUR INTEGRATOR KEY'

    @"
        {    
            "Username" : "$userName",
            "Password" : "$password",
            "IntegratorKey" : "$integratorKey"
        }
"@
}

function logon {
    [string] $loginURL = 'https://demo.docusign.net/restapi/v2/login_information'
    $headers = 
        @{
            "X-DocuSign-Authentication"=$(logonParams);
            "accept"="application/json";
            "content-type"="application/json";
        }

    $r = Invoke-WebRequest -uri $loginURL -headers $headers -method GET 
    $responseInfo = $r.content | ConvertFrom-Json 
    $baseURL = $responseInfo.loginAccounts.baseURL

    $baseURL
}

function createEnvelope {
    param ([string]$contractFile,
            [string]$baseURL
          )

    [string]$boundry = boundry
    $headers = 
    @{
        "X-DocuSign-Authentication"=$(logonParams);
        "accept"="application/json";
        "content-type"="multipart/form-data; boundary=$boundry";
    }

    [string]$formData = @"
--$boundry
Content-Type: application/json

{
  "status":"sent",
  "emailBlurb":"$recipientFirstName, Here is a test contract that I uploaded to DocuSign and routed through their webservice API.",
  "emailSubject": "Test Contract $(date)",
  "authoritativeCopy" : "true",
  "documents": [
      {
          "name": "$contractFile",
          "documentId":"1",
          "order":"1"
      }
  ],
  "recipients": {
    "signers" : [{
      "email" : "$recipientEmail",
      "name"  : "$recipientName",
      "title" : "$recipientTitle",
      "recipientId":"1",
      "tabs"  : {
            "signHereTabs" : [{ 
                "anchorString" : "//SIGNATURE//" 
            }],
            "fullNameTabs" : [{ 
                "anchorString" : "//SIGNATURE_NAME//",
                "font" : "Calibri",
                "fontSize" : "Size11",
                "anchorYOffset" : -10
            }],
            "titleTabs"    : [{ 
                "anchorString" : "//SIGNATURE_TITLE//",
                "font" : "Calibri",
                "fontSize" : "Size11",
                "anchorYOffset" : -10
            }],
            "dateTabs"     : [{ 
                "anchorString" : "//SIGNATURE_DATE//",
                "font" : "Calibri",
                "fontSize" : "Size11",
                "anchorYOffset" : -10
            }],
            "textTabs"     : [
                { 
                    "anchorString" : "//INVOICE_NAME//",
                    "font" : "Calibri",
                    "fontSize" : "Size11",
                    "anchorYOffset" : -10,
                    "value" : "My Invoice Name",
                },
                { 
                    "anchorString" : "//INVOICE_ADDRESS1//",
                    "font" : "Calibri",
                    "fontSize" : "Size11",
                    "anchorYOffset" : -10,
                    "value" : "My Invoice Address 1",
                },
                { 
                    "anchorString" : "//INVOICE_ADDRESS2//",
                    "font" : "Calibri",
                    "fontSize" : "Size11",
                    "anchorYOffset" : -10,
                    "value" : "My Invoice Address 2",
                },
                { 
                    "anchorString" : "//INVOICE_ADDRESS3//",
                    "font" : "Calibri",
                    "fontSize" : "Size11",
                    "anchorYOffset" : -10,
                    "value" : "My Invoice Address 3",
                },
                { 
                    "anchorString" : "//INVOICE_EMAIL//",
                    "font" : "Calibri",
                    "fontSize" : "Size11",
                    "anchorYOffset" : -10,
                    "value" : "[email protected]"
                }
            ],
       }
    }]
  }
}

--$boundry
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Transfer-Encoding: base64
Content-Disposition: file; filename="$mainFile";documentid=1

$(encodeFile $contractFile) 

--$boundry--
"@

    $envelopeURL = "$baseURL/envelopes"

    Invoke-WebRequest -uri $envelopeURL -headers $headers -body $formData -method POST
}

$baseURL = logon
createEnvelope "contract.docx" $baseURL

Upvotes: 1

Rickey S
Rickey S

Reputation: 1244

This would be done through the DocuSign API. You can build a template based on that contract and add the fields that needs data in them. Then when creating the envelope you can set the data that is populated within those fields.

More info can be found here.

EDIT:

Sample code can be found here

Custom Fields refer to Envelope Custom Fields which are an element that can be used to record information about the envelope, help search for envelopes and track information, not for tabs.

You'll want textTab:

    <textTabs>
        <text>
          <anchorIgnoreIfNotPresent>sample string 35</anchorIgnoreIfNotPresent>
          <anchorString>sample string 31</anchorString>
          <anchorUnits>sample string 34</anchorUnits>
          <anchorXOffset>sample string 32</anchorXOffset>
          <anchorYOffset>sample string 33</anchorYOffset>
          <conditionalParentLabel>sample string 39</conditionalParentLabel>
          <conditionalParentValue>sample string 40</conditionalParentValue>
          <documentId>sample string 26</documentId>
          <pageNumber>sample string 28</pageNumber>
          <recipientId>sample string 27</recipientId>
          <tabId>sample string 36</tabId>
          <templateLocked>sample string 37</templateLocked>
          <templateRequired>sample string 38</templateRequired>
          <xPosition>sample string 29</xPosition>
          <yPosition>sample string 30</yPosition>
          <bold>sample string 21</bold>
          <font>sample string 20</font>
          <fontColor>sample string 24</fontColor>
          <fontSize>sample string 25</fontSize>
          <italic>sample string 22</italic>
          <tabLabel>sample string 19</tabLabel>
          <underline>sample string 23</underline>
          <concealValueOnDocument>sample string 16</concealValueOnDocument>
          <disableAutoSize>sample string 17</disableAutoSize>
          <locked>sample string 15</locked>
          <maxLength>18</maxLength>
          <name>sample string 10</name>
          <originalValue>sample string 12</originalValue>
          <required>sample string 14</required>
          <value>sample string 11</value>
          <width>13</width>
          <requireAll>sample string 9</requireAll>
          <requireInitialOnSharedChange>sample string 7</requireInitialOnSharedChange>
          <senderRequired>sample string 8</senderRequired>
          <shared>sample string 6</shared>
          <validationMessage>sample string 5</validationMessage>
          <validationPattern>sample string 4</validationPattern>
          <formula>sample string 3</formula>
          <height>1</height>
          <isPaymentAmount>sample string 2</isPaymentAmount>
        </text>
      </textTabs>

Upvotes: -1

Related Questions