dermd
dermd

Reputation: 167

Is it possible to retrieve Docusign Templates or Power Form fields through Java API

I've been playing around with the Docusign API a bit and I've only been able to find information on requesting signatures or retrieving documents.

I have a number of powerforms created from templates which were generated from some pdfs. What I'd like to do is to somehow retrieve either the templates or powerforms so I can pull the fields and map them to another system. In this way when a powerform is submitted I get the document through connect and then can store the fields in a seperate system based on the mappings. All of which I'm doing through a set of java services.

Is this even possible with the API and if so has anyone done anything similar before or can you point me in the direction of any examples or documentation?

Thanks in advance for any help or suggestions, Derm

EDIT

As an update on this I did try using the

https://demo.docusign.net/restapi/v2/accounts/xxxxxx/templates

to get all my template ids and then

https://demo.docusign.net/restapi/v2/accounts/xxxxxx/templates/{template-id}

to get the template definition. In the REST developer guide the sample response looks to have a customfields section

"customFields":{
    "listCustomFields":[{
        "name":"String content",
        "required":"String content",
        "show":"String content",
        "value":"String content",
        "listItems":["String content"]
    }],
    "textCustomFields":[{
        "name":"String content",
        "required":"String content",
        "show":"String content",
        "value":"String content" 
    }]
},

However, I don't see any such section in my response (sample below with data x'd out). I did add a few sample custom fields to my template so am wondering why there are none coming back or if I'm maybe not specifying them correctly?

{  "envelopeTemplateDefinition": 
  {    "templateId": "xxx",    
     "name": "xxx",    
     "shared": "true",    
     "password": "",    
     "description": "",    
     "lastModified": "xxx",    
     "pageCount": x,    
     "uri": "xxx",    
     "folderName": "xxx",    
     "folderId": "xxx",    
     "folderUri": "xxx",    
     "owner": {      
          "userName": "xxx",      
          "email": "xxx",      
          "userId": "xxx"    
     }  
  },  
  "documents": [    
   {      
     "documentId": "xxx",      
     "uri": "xxx",      
     "name": "xxx",      
     "order": "xxx",      
     "pages": "xxx"    
   }  
  ],  
  "recipients": 
  {    
     "signers": [      
     {        
          "defaultRecipient": "xxx",        
          "signInEachLocation": "xxx",        
          "name": "",        
          "email": "",        
          "recipientId": "xxx",        
          "accessCode": "",        
          "requireIdLookup": "xxx",        
          "routingOrder": "1",        
          "note": "",        
          "roleName": "xxx",        
          "templateLocked": "xxx",        
          "templateRequired": "xxx",        
          "inheritEmailNotificationConfiguration": "xxx"      
     }     
     ],    
     "agents": [],    
     "editors": [],    
     "intermediaries": [],    
     "carbonCopies": [],    
     "certifiedDeliveries": [],    
     "inPersonSigners": [],    
     "recipientCount": "1"  
  },  
  "notification": 
  {    
     "reminders": 
     {      
         "reminderEnabled": "xxx",      
         "reminderDelay": "0",      
         "reminderFrequency": "0"    
     },    
     "expirations": 
     {      
          "expireEnabled": "xxx",      
          "expireAfter": "xxx",      
          "expireWarn": "0"    
     }  
  },  
  "emailSubject": "xxx",  
  "emailBlurb": "",  
  "signingLocation": "xxx",  
  "authoritativeCopy": "xxx",  
  "enforceSignerVisibility": "xxx",  
  "enableWetSign": "xxx",  
  "allowMarkup": "xxx"
}

If anyone has any ideas why the customFields section maybe missing from above it'd be great to know. For the moment I'm going to try out Kims approach below (thanks Kim!) and see if that covers what I'm trying to do...

Upvotes: 0

Views: 1965

Answers (2)

Javed Usmani
Javed Usmani

Reputation: 21

I know its a very late reply to this post, But it may help some other needed guy's. I am using REST Api to retrieve the signed document from docusig account.

// get docusign details

$email = "enter your associated docusign account email";

$password = "enter your associated docusign account password";

$integratorKey = "enter your associated docusign account integrated key";

// pass your account information into the header

$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

// retrieve document from docusign demo account

$url = "https://demo.docusign.net/restapi/v2/login_information";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));

$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
    $status = false;
}

$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);       

// get document
$documentId = 1;  //provide your document id
$curl = curl_init($baseUrl . "/envelopes/" . $envelopeID . "/documents/". $documentId."?show_changes=" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
   'Content-Type: application/pdf',
   "X-DocuSign-Authentication: $header" )
);

$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200) {
            $status = false;
}
curl_close($curl);

//you can print your response here or if you want to save as a pdf then you can add below code

$path = APPLICATION_PATH  . 'your path';
$filename ="your file name";


chmod("$path", 0777);
file_put_contents("$path/$filename", $json_response);

Upvotes: 0

Kim Brandl
Kim Brandl

Reputation: 13500

The DocuSign Developer Center (http://www.docusign.com/developer-center) contains a wealth of information about using the DocuSign APIs -- definitely check that out as well (in addition to the REST API Guide you've already found).

Regarding the scenario that you describe -- i.e., wanting to use the API to determine what fields are defined in a DocuSign Template -- it's certainly possible. Simply execute a Get Recipients request with querysting parameter include_tabs set to true and include the Template ID in place of where the Envelope ID would normally go in the request URL. For example:

GET https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/{{templateId}}/recipients?include_tabs=true&include_extended=true

The response will include all recipient roles specified for the Template, and for each recipient role, the tabs (fields) that belong to the recipient role. Here's an example response for a Template that contains two recipient roles (both type = signer), with each recipient role owning several different tabs (fields) of various types:

{
    "signers": [
        {
            "tabs": {
                "signHereTabs": [
                    {
                        "name": "SignHere",
                        "tabLabel": "Sign Here",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "10",
                        "yPosition": "100",
                        "tabId": "15311994-b09a-4ea5-b24d-d185875ba378"
                    },
                    {
                        "name": "Sign Here",
                        "tabLabel": "Signature 8",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "2",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "71",
                        "yPosition": "107",
                        "tabId": "ff79b73d-ad5b-423c-9a37-70547e928100"
                    }
                ],
                "initialHereTabs": [
                    {
                        "name": "Initial Here",
                        "tabLabel": "Initial 31",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "3",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "75",
                        "yPosition": "106",
                        "tabId": "6be4892d-a2d2-4f50-b0ff-0acd5108dc6d"
                    }
                ],
                "textTabs": [
                    {
                        "height": 11,
                        "validationPattern": "",
                        "validationMessage": "",
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "name": "Text",
                        "value": "",
                        "width": 42,
                        "required": "true",
                        "locked": "false",
                        "concealValueOnDocument": "false",
                        "disableAutoSize": "false",
                        "tabLabel": "Address",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "108",
                        "yPosition": "142",
                        "tabId": "0039105d-2a47-4937-874f-00307c54bca4"
                    },
                    {
                        "height": 11,
                        "validationPattern": "",
                        "validationMessage": "",
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "name": "Text",
                        "value": "",
                        "width": 42,
                        "required": "true",
                        "locked": "false",
                        "concealValueOnDocument": "false",
                        "disableAutoSize": "false",
                        "tabLabel": "City",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "180",
                        "yPosition": "142",
                        "tabId": "1f071721-fe91-49cd-ab43-a316548adea6"
                    },
                    {
                        "height": 11,
                        "validationPattern": "",
                        "validationMessage": "",
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "name": "Text",
                        "value": "",
                        "width": 42,
                        "required": "true",
                        "locked": "false",
                        "concealValueOnDocument": "false",
                        "disableAutoSize": "false",
                        "tabLabel": "State",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "250",
                        "yPosition": "142",
                        "tabId": "687f4dc4-736d-4a45-b195-29b44b7cb8a9"
                    },
                    {
                        "height": 11,
                        "validationPattern": "",
                        "validationMessage": "",
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "name": "Text",
                        "value": "",
                        "width": 42,
                        "required": "true",
                        "locked": "false",
                        "concealValueOnDocument": "false",
                        "disableAutoSize": "false",
                        "tabLabel": "Zip",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "343",
                        "yPosition": "142",
                        "tabId": "e94a42fc-a38b-4536-a25a-008db64376a3"
                    }
                ],
                "radioGroupTabs": [
                    {
                        "documentId": "1",
                        "recipientId": "1",
                        "groupName": "IsUSCitizen",
                        "radios": [
                            {
                                "pageNumber": "1",
                                "xPosition": "328",
                                "yPosition": "195",
                                "value": "Yes",
                                "selected": "false",
                                "tabId": "8cd7c1c3-41d3-4803-9a25-d4798e4f8465",
                                "required": "True",
                                "locked": "False"
                            },
                            {
                                "pageNumber": "1",
                                "xPosition": "328",
                                "yPosition": "217",
                                "value": "No",
                                "selected": "false",
                                "tabId": "c8481da7-5bf3-4648-a002-feb5b697746c",
                                "required": "True",
                                "locked": "False"
                            }
                        ]
                    }
                ]
            },
            "signInEachLocation": "false",
            "name": "",
            "email": "",
            "recipientId": "1",
            "recipientIdGuid": "dd9dda12-13a8-4f91-ba77-f9427ce9c4c6",
            "requireIdLookup": "false",
            "routingOrder": "1",
            "roleName": "Signer1",
            "status": "created",
            "templateLocked": "false",
            "templateRequired": "false"
        },
        {
            "tabs": {
                "signHereTabs": [
                    {
                        "name": "Sign Here",
                        "tabLabel": "Signature 9",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "2",
                        "recipientId": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
                        "pageNumber": "1",
                        "xPosition": "71",
                        "yPosition": "194",
                        "tabId": "fd8eff65-105f-46ae-9f28-305790c9d4e7"
                    }
                ],
                "initialHereTabs": [
                    {
                        "name": "Initial Here",
                        "tabLabel": "Initial 32",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "3",
                        "recipientId": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
                        "pageNumber": "1",
                        "xPosition": "75",
                        "yPosition": "154",
                        "tabId": "b01922a7-f20a-4dc4-9327-96e592733ca9"
                    }
                ],
                "numberTabs": [
                    {
                        "validationPattern": "",
                        "validationMessage": "",
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "name": "Text",
                        "value": "",
                        "width": 42,
                        "required": "true",
                        "locked": "false",
                        "concealValueOnDocument": "false",
                        "disableAutoSize": "false",
                        "tabLabel": "Quantity",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
                        "pageNumber": "1",
                        "xPosition": "43",
                        "yPosition": "396",
                        "tabId": "37cfcb7d-4357-4c6b-a9b8-500e5e9dc9b6"
                    }
                ],
                "listTabs": [
                    {
                        "listItems": [
                            {
                                "text": "Regular",
                                "value": "Regular",
                                "selected": "false"
                            },
                            {
                                "text": "Express",
                                "value": "Express",
                                "selected": "false"
                            }
                        ],
                        "value": "",
                        "width": 78,
                        "shared": "false",
                        "requireInitialOnSharedChange": "false",
                        "tabLabel": "ShippingMethod",
                        "bold": "false",
                        "italic": "false",
                        "underline": "false",
                        "documentId": "1",
                        "recipientId": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
                        "pageNumber": "1",
                        "xPosition": "121",
                        "yPosition": "395",
                        "tabId": "6f663d22-3632-486b-a1f5-7455c665b9d8"
                    }
                ]
            },
            "signInEachLocation": "false",
            "name": "",
            "email": "",
            "recipientId": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
            "recipientIdGuid": "e3a92e6d-1533-4785-a814-2e4e7f96bef5",
            "requireIdLookup": "false",
            "routingOrder": "2",
            "roleName": "Signer2",
            "status": "created",
            "templateLocked": "false",
            "templateRequired": "false"
        }
    ],
    "agents": [],
    "editors": [],
    "intermediaries": [],
    "carbonCopies": [],
    "certifiedDeliveries": [],
    "inPersonSigners": [],
    "recipientCount": "2"
}

The DocuSign REST API guide (that you linked to in your comment) contains information about the various tab types and the properties that each tab type contains.

Upvotes: 1

Related Questions