Retrieving Custom Fields from a Template in Docusign - docusignapi

Hello Stack Overflow world,
I am currently trying to pull back all custom fields associated with a template I have created but I keep getting a 200 code with no data in the body. Anybody know what I am doing wrong?
Endpoint:
GET /v2/accounts/{myaccountID}/templates/{mytemplateId}/custom_fields
Headers: {"accept":"application/json", "Content-Type":"application/json"}
Response Headers:
{
"cache-control": "no-cache",
"content-length": "57",
"content-type": "application/json; charset=utf-8",
"x-ratelimit-reset": "1518814800",
"x-ratelimit-limit": "1000",
"x-ratelimit-remaining": "999",
"x-docusign-tracetoken": "{redacted}",
"date": "Fri, 16 Feb 2018 20:00:27 GMT",
"connection": "close",
"strict-transport-security": "max-age=31536000; includeSubDomains"
}
Body:
{}

The request that you've posted (GET /v2/accounts/{myaccountID}/templates/{mytemplateId}/custom_fields) will return any Envelope Custom Fields that the template contains. Envelope Custom Fields are the collection of textCustomFields and/or listCustomFields that can be used to specify metadata for the Envelope that isn't available/visible to recipients in any way. Is that truly the type of data that you're intending to retrieve?
If you're not really intending the retrieve Envelope Custom Fields (as described above), but rather, want to retrieve the tabs (fields) that are visible to recipients in the document(s) of the Envelope, then you should instead use the Get Template request:
GET /v2/accounts/{myaccountID}/templates/{mytemplateId}
The response body will contain all information for the Template, including a (top-level) recipients property that contains an array of signers. For each signer specified, the tabs property will contain the tabs (fields) that are assigned to that signer. For the example, the following JSON shows the recipients portion of a Get Template response for a template that contains a single signer who is assigned just one text tab.
{
...
"recipients": {
"signers": [
{
"tabs": {
"textTabs": [
{
"height": 33,
"isPaymentAmount": "false",
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"value": "",
"originalValue": "",
"width": 60,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"maxLength": 100,
"tabLabel": "Address",
"font": "lucidaconsole",
"bold": "false",
"italic": "false",
"underline": "false",
"fontColor": "black",
"fontSize": "size9",
"documentId": "92876756",
"recipientId": "72490903",
"pageNumber": "1",
"xPosition": "70",
"yPosition": "40",
"tabId": "879ff828-53d2-40af-97a7-a9b1f71a1a87",
"templateLocked": "false",
"templateRequired": "false"
}
]
},
...
}
],
...
},
...
}

Related

Auto populating all custom fields in an envelope across multiple templates

As outlined in the API documentation linked below
https://developers.docusign.com/docs/esign-rest-api/v2/reference/envelopes/enveloperecipienttabs/#automatically-populating-tabs
We are trying to populate custom fields (textTabs with the same tabLabel) throughout an existing envelope for a recipient on all documents using the update method (PUT). Note: We are testing this in our Dev environment
When sending the JSON body data
{
"textTabs": [
{
"value": "test",
"tabLabel": "\\*firstName"
}
]
}
Without specifying a tabID as this does not seem to be required in the included documentation provided.
We are receiving this JSON body error response.
{
"textTabs": [
{
"requireAll": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"localePolicy": {},
"recipientId": "1",
"errorDetails": {
"errorCode": "INVALID_TABID",
"message": "Invalid TabId specified. TabId:not specified."
},
"tabType": "text"
}
]
}
If we do specify a tabID (which appears to be unique per DocuSign envelope) it does work for that single specified textTab within the envelope and nothing else - See below JSON body response.
{
"textTabs": [
{
"isPaymentAmount": "false",
"validationPattern": "",
"validationMessage": "",
"shared": "true",
"requireInitialOnSharedChange": "false",
"senderRequired": "false",
"requireAll": "false",
"value": "test",
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"maxLength": "4000",
"tabLabel": "\\*firstName",
"font": "lucidaconsole",
"bold": "false",
"italic": "false",
"underline": "false",
"fontColor": "black",
"fontSize": "size10",
"localePolicy": {},
"documentId": "2",
"recipientId": "1",
"xPosition": "20",
"yPosition": "165",
"width": "84",
"height": "22",
"tabId": "d31e1587-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"templateLocked": "false",
"templateRequired": "false",
"tabOrder": "0",
"tabType": "text"
}
]
}
Additionally if we are to use the \\* prefix as suggested in the documentation, the tabLabel is updated to "\\*firstname"
This does not seem like the correct behavior. Is anyone able to point me in the right direction? or am I interpreting something wrong here?
You have to specify a specific tab when setting tab values, there's no mechanism that I know of to do wildcard or set all tabs in one swoop.
You could make GET call(s) first to retrieve all the tabs and then set up a single call that sets them all (by iterating through all the tabs and fetching the tabId for each)
There may be one way to do this differently, but it requires that the tabs have tabLabel and if it's the same, you can set it for all tab with the same tabLabel in one call (without specifying tabId) but not sure that would work for you because I don't see that in the response when you created the tabs.

Calling EnvelopesApi#update_document_tabs returns an error

I want to update all the tabs for a document at once. The document's envelope was created from a template which already has the recipients and tabs defined, and I am calling this endpoint with the following payload to update the tabs:
{
"textTabs": [
{
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"value": "Some value",
"originalValue": "Original value",
"required": "false",
"locked": "true",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"maxLength": "4000",
"tabLabel": "Address",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size12",
"localePolicy": {},
"documentId": "1",
"recipientId": "18870af6-8c21-4e4c-934c-ac329b6f7374",
"pageNumber": "1",
"xPosition": "52",
"yPosition": "94",
"width": "132",
"height": "18",
"tabId": "032f2d80-7a93-4a7c-b969-aea2249fbd04",
"templateRequired": "false",
"tabType": "text"
}
]
}
I get the following error in response:
{
"errorCode": "INVALID_TAB_OPERATION",
"message": "The Tab specified is not valid for the requested operation. Updated tabs must all be Strikethrough or SmartSection tabs if you're not specifying a valid recipient."
}
recipientId is set to the value I received from this endpoint, but I've also tried setting it to "1" which is the recipientId I pass when creating the template.
What is the correct way to call this endpoint?
Yulian, It appears there's a bug in the UpdateDocumentTabs endpoint that is causing this issue and we're looking into it and hope to have an update soon.
As a workaround, you can use the UpdateRecipientTabs endpoint for now. I realize this would mean making additional API calls for the same purpose. If you need your API hourly quota increased - you can contact me and I can help with that.

SalesForce DocuSign REST API createAndSendenvelope

Can anyone give a sample apex code REST API example for createAndSendenvelope. I am using demo DocuSign sandbox and I get INCOMPLETE ENVELOPE error. I do have all the required elements in my envelope, so looking to see what I am missing or if I am not creating it in a correct manner. Below is the json that I pass as request and I get response: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"status": "created",
"recipients": {
"signers": [{
"tabs": {
"signHeretabs": [{
"yPosition": "15",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"recipientId": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentid": "1",
"anchorYoffset": null,
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Sign Here",
"anchorIgnoreIfNotPresent": "true"
}],
"initialsTabs": [{
"yPosition": "45",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"receipientId": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentId": "1",
"anchorYoffset": null,
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Initials Here",
"anchorIgnoreIfNotPresent": "true"
}],
"dateSignedTabs": [{
"yPosition": "65",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"receipientid": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentid": "1",
"anchorYoffset": "-5",
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Date Signed",
"anchorIgnoreIfNotPresent": "true"
}]
},
"routingorder": "1",
"rolename": "First Signer",
"recipientid": "1",
"name": "Marisol L Testcase",
"email": "testfd1#gcpa.com"
}]
},
"emailsubject": "TestDocuSign Call",
"emailBlurb": "Test Email Blurb",
"documents": [{
"name": "Name1",
"fileExtension": ".txt",
"documentId": "1",
"documentBase64": null
}]
}
--BOUNDARY
Content-Type: application/octet-stream
Content-Disposition: file; filename="Name1"; documentid=1
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIHNhbXBsZSBmaWxlIHVwbG9hZCBmb3IgdGVzdGluZy4=
--BOUNDARY--
Update: I could get rid of the boundary parameter error and now get "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Envelope definition missing."
You should not put "documentBase64": null in the "documents" node as you are already passing document as multipart request and "fileExtension" should be "txt" not ".txt". Now coming to the tabs assignment, you are mixing two strategies, one is X/Y position and another is Anchor String. You should use one of them, X/Y position will put a DocuSign tab at specified X/Y position, whereas AnchorString will try to find the that string in the document and if it finds then attaches the DocuSign tab on it. And there is no fall back strategy, means if anchor string is not available then put X/Y position, this is not possible. So either your document should have anchor string then use Anchor String strategy else, remove Anchor string related property from JSON and place tags as per X/Y position.

texttabs not being set using rest api create envelope

Wondering what I am missing or doing wrong here as the value for the tabs are not being set when creating the envelope.
In the JSON code below I am trying to default values for the text tabs for recipient 5.
{
"emailSubject":"Allowance Agreement - AK Anne Klein Footwear - ytd .doc",
"emailBlurb":"DEV - Please complete the Vendor Allowance Agreement required for your Supplier setup with Zappos.com or 6pm.com. \n\n Please reach out to your Vendor Support team member or vendorsupport#zappos.com with any questions.",
"status":"sent",
"compositeTemplates":[
{
"compositeTemplateId": "1",
"inlineTemplates":[
{
"sequence":"1",
"documents": [
{
"documentId": "1",
"name": "Allowance Agreement - AK Anne Klein Footwear - ytd .doc.doc"
}
],
"customFields": {
"textCustomFields": [
{
"name": "Node ID",
"required": "true",
"show": "true",
"value": "658824"
}
]
},
"recipients":{
"signers":[
{
"email":"email#email.com",
"name":"v",
"recipientId":1,
"roleName":"Vendor"
},
{
"email":"email#email.com",
"name":"test",
"recipientId":2,
"roleName":"Vendor Support"
},
{
"email":"email#email.com",
"name":"ap",
"recipientId":3,
"roleName":"AP"
},
{
"email":"email#email.com",
"name":"f",
"recipientId":4,
"roleName":"Finance"
},
{
"email":"email#email.com",
"name":"ap",
"recipientId":5,
"roleName":"AP2",
"tabs":{
"textTabs":[
{
"tabLabel":"txtVendorId",
"value":"100023"
},
{
"tabLabel":"txtSupplierName",
"value":"AK Anne Klein Footwear"
},
{
"tabLabel":"txtSupplierId",
"value":"253"
}
]
}}
]
}
}
],
"serverTemplates":[
{
"sequence":"2",
"templateId":"A3B4F6BB-639A-486F-8C84-826295142F21"
}
]
}
]
}
When I look at the envelope tabs here is what I get for the 5th recipient:
"textTabs": [
{
"height": 22,
"isPaymentAmount": "false",
"validationPattern": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"name": "Text",
"value": "",
"width": 300,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "txtVendorId",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size9",
"documentId": "1",
"recipientId": "5",
"pageNumber": "2",
"xPosition": "217",
"yPosition": "651",
"tabId": "2179efb5-9f59-4bb7-895e-da868fba9919"
},
{
"height": 22,
"isPaymentAmount": "false",
"validationPattern": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"name": "Text",
"value": "",
"width": 342,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "txtSupplierName",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size9",
"documentId": "1",
"recipientId": "5",
"pageNumber": "2",
"xPosition": "172",
"yPosition": "670",
"tabId": "2c6e59b1-6a4f-4f5f-a873-33398c78e408"
},
{
"height": 22,
"isPaymentAmount": "false",
"validationPattern": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"name": "Text",
"value": "",
"width": 354,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "txtSupplierId",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size9",
"documentId": "1",
"recipientId": "5",
"pageNumber": "2",
"xPosition": "172",
"yPosition": "690",
"tabId": "614eb20b-5536-45db-b64a-84a475cdc44d"
}
]
* EDIT *
adding final part of envelopes tabs and screen captures of recipients and one tab...
},
"isBulkRecipient": "false",
"name": "ap",
"email": "email#email.com",
"recipientId": "5",
"recipientIdGuid": "77e255d8-a6d6-47a8-98ee-0f3829631d76",
"requireIdLookup": "false",
"userId": "8d7f443b-7adf-4cfa-8368-296aee88e959",
"routingOrder": "5",
"roleName": "AP2",
"status": "created",
"totalTabCount": "5"
}
* Workaround *
Since I was not able to set the tab values at creation time I tried the following:
Tried to create a PUT request to update the tabs using the uri for the tab for the recipient /envelopeid/recipients/5/tabs and passing the JSON for the text tabs as.
{
"textTabs":[
{
"tabLabel": "txtVendorId",
"value":"123"
}
]
}
Passing the JSON above I would get a response that the tab was not found on the envelope
{
"requireAll": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"recipientId": "5",
"tabId": "00000000-0000-0000-0000-000000000000",
"errorDetails": {
"errorCode": "INVALID_TAB_OPERATION",
"message": "The Tab specified is not valid for the requested operation. The Tab specified is not valid for the requested operation. Tab not found in envelope."
}
My second step was to actually get the tabId value from the created envelope instead of using the tab lable (something that I would not have before creating the envelope).
By calling /envelopeid/recipients/5/tabs with the tabId in the JSON instead like
{
"textTabs":[
{
"tabId": "57135910-fe34-417d-a4e3-fc7d6c4a42ed",
"value":"123"
}
]
}
Then the field value got updated correctly.
In conclusion, for my workaround will need three calls to DocuSign to be able to set the default values for this recipient:
Create Envelope
Get Recipient tabs (to get value of tab ids)
Update tab values using tab ids.
Are you positive you are correctly matching your recipients to valid roles you've configured on the Template?
For instance, I see that for recipient #5 you are assigning them to the "AP2" role, does that exact role exist in your template when you login to the website and view the template?
I'm sorry for the very long delay on an answer, your JSON needs one small tweek.
You need to change your sequence of your serverTemplates to 1, assigning the values to the same template.
"serverTemplates":[
{
"sequence":"1",
}
This will remove the need for the GET/PUT (although you can still do the GET to verify information if you'd like)

Get template roles (REST API)

I'm interested in getting roles from templates to populate them correctly and keep that up to date automatically.
Is it somehow possible to get that using REST API?
There's the "Get Account Template by ID - v2/accounts/:accountId/templates/:templateId" request but it seems to return little useful info regarding roles or recipients.
Using the REST API, you can get recipient Role Names for a Template by simply executing a "GET Envelope Recipients" request, where you specify the Template Id in place of the Envelope Id. For example:
GET https://demo.docusign.net/restapi/v2/accounts/{accountId}/envelopes/{templateId}/recipients?include_tabs=false&include_extended=true
The response to this request will contain an array of recipient objects for each recipient type (i.e.: signers, agents, editors, intermediaries, carbonCopies, certifiedDeliveries, inPersonSigners); each recipient object will contain the property roleName. Here's an example response for a template that contains 3 recipients -- 2 signers and one CC recipient:
{
"signers": [
{
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "5741ec70-b056-44eb-b462-eceee88ddf77",
"requireSignerCertificate": "false",
"requireIdLookup": "false",
"routingOrder": "1",
"roleName": "Signer 1",
"status": "created",
"templateLocked": "false",
"templateRequired": "false"
},
{
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "c64d4567-2efd-422d-9b0a-a5427aa2512d",
"requireSignerCertificate": "false",
"requireIdLookup": "false",
"routingOrder": "2",
"roleName": "Signer 2",
"status": "created",
"templateLocked": "false",
"templateRequired": "false"
}
],
"agents": [],
"editors": [],
"intermediaries": [],
"carbonCopies": [
{
"name": "Legal Team",
"email": "email3#outlook.com",
"recipientId": "a63e3714-adc2-4e05-b2c5-b3c3bbf50aa2",
"requireIdLookup": "false",
"routingOrder": "3",
"roleName": "Legal Team",
"status": "created",
"templateLocked": "true",
"templateRequired": "true"
}
],
"certifiedDeliveries": [],
"inPersonSigners": [],
"recipientCount": "3"
}

Resources