Unexpected behavior with composite templates - docusignapi

I am having an issue with understanding how inline templates work. I have 2 server templates and 2 inline templates, 1 inline template to marry up with a server template. I want to see if I don't fill in the info for the inline template that the envelope still works. Here is my request:
Request
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "8a3a21af-4348-45e1-85b9-72a331c9c67a"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": []
}
}
],
"document": {
"documentId": "2",
"name": "FinalSale.docx",
"fileExtension": "docx",
"documentBase64": [bytearray]
}
},
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "d22048be-4bfe-43c2-9acf-3d5bcd79144f"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Kathy Keaton",
"email": "KathyKeaton1#outlook.com",
"recipientId": "1",
"accessCode": "5000",
"routingOrder": "1",
"roleName": "##Buyer1"
},
{
"name": "Kathy Lloyd",
"email": "KathyLloyd1#outlook.com",
"recipientId": "2",
"accessCode": "5000",
"routingOrder": "2",
"roleName": "##Seller1"
}
]
}
}
],
"document": {
"documentId": "1",
"name": "Going to test out signatures and initials.docx",
"fileExtension": "docx",
"documentFields": [
{
"name": "dgsvalue",
"value": "dgs-222"
}
],
"documentBase64": [bytearray]
}
}
],
"status": "sent",
"emailSubject": "Please sign the following 2 documents at 2:39 PM"
}
Response
{
"envelopeId": "f8a090cf-ddc3-4612-8f24-9ff13beddc48",
"uri": "/envelopes/f8a090cf-ddc3-4612-8f24-9ff13beddc48",
"statusDateTime": "2017-02-01T19:39:26.2330000Z",
"status": "sent"
}
I was assuming that the inline templates would have to supply all the signers. The role names in the 2 templates are the same ( ##Buyer1 and ##Seller1 are in both templates ). I would have thought that not having the inline template filled in would mean that it would fail on that particular document. I was wrong, but I'm not sure why. Did it succeed because the role names are the same on both server templates and specifying it for one inline template was enough?

You are not required to supply all the signers in an inline template.
Here are the complete rules for Composite template usage.
Quoting some of them here.
Each CompositeTemplate adds a new document and templates overlay into
the envelope. For each CompositeTemplate these rules are applied:
Templates are overlaid in the order of their Sequence value.
If Document is not passed into the system, the first template’s
document (based on template’s Sequence value) is used.
Last in wins in all cases except for the document (i.e. envelope
information, recipient information, secure field information). This
was done to keep things simple. There is no special casing.
For example, if you want higher security on a tab, then that needs to be specified in the last template in which the tab is included. If you want higher security on a role recipient it needs to be in the last template in which that role recipient is specified.
Recipient matching is based on Recipient Role and Routing Order. If there are matches, the recipient information is merged together. A final pass is done on all CompositeTemplates, after all template overlays have been applied, to collapse recipients with the same email, username and routing order. This prevents having the same recipients at the same routing order.

Related

Attach document to existing template docusign Rest API

I am able to send a POST request to send an existing template for signing. What I'm trying to do now is attach a PDF to the signature template. The attached PDF does not need to be signed / is not a template. It is just a PDF copy of a document as an appendix to the contract.
The request is going through ok, but I'm getting the error: "TAB_PAGENUMBER_IS_NOT_IN_DOCUMENT",\r\n "message": "The pagenumber specified in the tab element is not in the document that the tab refers to. Tab on Page 8 of Document 1 for Recipient 1"
JSON:
{
"emailSubject": "Please sign this document set",
"templateId": "xxxxxxx",
"templateRoles": [
{
"email": "email#example.com",
"roleName": "Buyer",
"name": "Buyer Name"
}
],
"documents": [
{
"signerMustAcknowledge": "no_interaction",
"order": "asc",
"name": "MyCompany Quote",
"includeInDownload": true,
"documentId": "2",
"documentBase64": "<base64string>",
"display": "inline"
},
],
"status": "sent"
}
How to attach a document to an online template?
The error you are seeing is because DocuSign will try to replace the document in the template with the file you are providing.
You should be able to add this additional document by using composite templates instead. https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-composite-template-embedded/
Here is a sample:
{
"compositeTemplates": [
{
"compositeTemplateId": "1",
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"email": "email#example.com",
"roleName": "Buyer",
"name": "Buyer Name"
}
]
},
"sequence": "1"
}
],
"serverTemplates": [
{
"sequence": "1",
"templateId": "xxxxxxx"
}
]
},
{
"compositeTemplateId": "2",
"document": {
"documentBase64": "<base64string>",
"documentId": "2",
"fileExtension": "pdf",
"name": "MyCompany Quote"
},
"inlineTemplates": [
{
"sequence": "1"
}
]
}
],
"emailSubject": "Please sign this document set",
"status": "sent"
}
The first composite template is used to populate your existing template with the signers information. The second composite template is where you add the additional document you want your users to sign. You can also include additional tabs inside the inlineTemplates if they are needed in the future

Docusign createEnvelope REST API with Composite Templates CANNOT_EXCLUDE_DOCUMENT Error

Using documentation at createEnvelope with composite templates
https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/
https://developers.docusign.com/esign-rest-api/guides/features/templates
When we attempt to use this API for multiple templates we are getting error similar to below
{\r\n \"errorCode\": \"CANNOT_EXCLUDE_DOCUMENT\",\r\n \"message\": \"This document cannot be excluded for this recipient. Recipient: Enbmgr Enbmgr cannot be excluded from Document:TalentEmploymentAgreemt_0617AqVT.pdf\"\r\n}"}}
When the sequence of the templates are changed it works fine. What could be the cause for this?
The account is set up with Document Visibity: Sender can set "must sign to view unless sender"
Error when sent with below sequence:
Templateid- f09dc354-efd6-437e-9410-5270b181a1f1 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- 8c919c05-ee1f-42c4-b521-861c5f2949b Roles: Emp
Templateid- 6b57ea78-5923-4c54-b4c1-15c8d5313e71 Roles: Emp, Mgr (sign in sequence enabled)
Success when sent with below sequence:
Templateid- 6b57ea78-5923-4c54-b4c1-15c8d5313e71 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- f09dc354-efd6-437e-9410-5270b181a1f1 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- 8c919c05-ee1f-42c4-b521-861c5f2949b Roles: Emp
Request giving error:
{
"emailSubject": "DocuSign API - Composite Templates",
"emailBlurb": "Composite Templates Sample 1",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "f09dc354-efd6-437e-9410-5270b181a1f1"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "8c919c05-ee1f-42c4-b521-861c5f2949bf"
}
],
"inlineTemplates": [
{
"sequence": "4",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {
"textTabs": [
{
"tabLabel": "\\*Market",
"value": " "
}
]
}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "5",
"templateId": "6b57ea78-5923-4c54-b4c1-15c8d5313e71"
}
],
"inlineTemplates": [
{
"sequence": "6",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
}
]
}
Request giving success:
{
"emailSubject": "DocuSign API - Composite Templates",
"emailBlurb": "Composite Templates Sample 1",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "6b57ea78-5923-4c54-b4c1-15c8d5313e71"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "f09dc354-efd6-437e-9410-5270b181a1f1"
}
],
"inlineTemplates": [
{
"sequence": "4",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "5",
"templateId": "8c919c05-ee1f-42c4-b521-861c5f2949bf"
}
],
"inlineTemplates": [
{
"sequence": "6",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {
"textTabs": [
{
"tabLabel": "\\*Market",
"value": " "
}
]
}
}
]
}
}
]
}
]
}
I've found that the last template looks like this
Template definition with excluded documents for a signer
How are excluded documents for signers setup in Docusign's application?
I suspect how the Roles and Tabs are distributed matters, yet I can't see your template or the API Json sent.
You can get the API log capture of the exact JSON/SOAP request posted by your API calls via Java to DocuSign by following steps explained at this DocuSign support article https://support.docusign.com/guides/ndse-user-guide-api-request-logging
Here is part of what you need to understand about Sequence numbers and physical order - In composite templates, physical order overrules the "index/sequence" per composite template node. The index is the internal glue, but not really the row order in the in-memory model. I suspect you really wanted to restart the sequence number in each node of "composite template" since you are saying I have "three" documents and x number of features and roles per document as both working and not working collapse to the following structure composite nodes structure except it looks like you had (corrected now) an extra "[" array grouping:
(corrected now in updated question)
"compositeTemplates": [{
"serverTemplates": [{
"inlineTemplates": [{
"document": ....
or to match yours:
"compositeTemplates": [
{},
{},
{}
]
This all supposes you want three documents, if you want one document, then you keep the server templates in the same array collection inside the composite node to be applied to the contributing document, one with the lowest sequence number. Remember in JSON/REST if the JSON is malformed aka includes more than needed, the API just ignores it as "client comments" and takes what it can use.
The lower the sequence: document node (not documents) between server, inline and document being 0 is how the "PDF/DOC bytes are determined, and the higher the sequence number the feature that wins aka doc vis in one template, vs another or the notification days number.
I will have to probably wait for the logs, however I think the clue to the issue on doc vis error is the "tabLabel": "\*Market" which goes from middle to last between the two examples. Anchor strings are envelope wide, so I suspect it "meets" the needed criteria for the feature for that role which is probably required per the template. You can put the all the roles in the last composite template node of the last inline template node and it will apply them to all the previous composite template nodes where they are not supplied by an inline template.
So there is a best practice document I am about to publish explaining this on complex template assembly in envelopes, however, hope this helps for now.
Please attach your logs so we can see the real example and determine which played into the results you are describing.

Docusign API - Create envelope, apply template, prefill values

Many questions address portions of my request, but I cannot seem to make a complete solution work. I have created a template on my site (it has various text fields, initial fields, and signature block). Single recipient, using anchor tags for the fields. When I take a .docx file, create an envelope via the api, I want to apply the template previously mentioned, and then prefill 4 text fields on the document/template.
Anchor tags are not placing the fields appropriately.
Any advise/suggestions?
Working request call is:
{
"documents":
[
{
"documentBase64":"<BASE64STREAM>",
"documentId":"3",
"fileExtension":"docx",
"name":"10001000_20170803_FILE"
}
],
"emailSubject": "TEST - Group Audit - 10001000",
"templateId": "TEMPLATE_ID",
"templateRoles" :
[
{
"email": "JDOE#email.com",
"name": "JOHN DOE",
"roleName": "signer1",
"tabs":
{
"textTabs":
[
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupname",
"value": "TEST GROUP ONE"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupnumber",
"value": "10001000"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "txt",
"value": "my#email.com"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "fein",
"value": "870142380"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "physicaladdress",
"value": "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
],
"status":"sent"
}
Based on the information you've provided, I understand your scenario to be as follows:
You've created a template via the DocuSign UI; that template contains a 'placeholder' document (which you will replace at run-time via your Create/Send Envlope API call) and defines the recipient(s) and tabs for that document.
When you create/send the envelope via API, you want to specify the document as part of the API request (i.e., to be used instead of the 'placeholder' document that the DocuSign template contains) and also auto-populate some of the tabs that the template defines.
If that's an accurate description of what you're trying to achieve, then you need to use Composite Templates in the API request structure. Here's an example of a Create/Send Envelope JSON request that uses composite templates (and contains data based upon the information you provided in your question):
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "TEMPLATE_ID"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "JOHN DOE",
"email": "JDOE#email.com",
"roleName": "signer1",
"tabs":
{
"textTabs":[
{
"tabLabel" : "groupname",
"value" : "TEST GROUP ONE"
},
{
"tabLabel" : "groupnumber",
"value" : "10001000"
},
{
"tabLabel" : "txt",
"value" : "my#email.com"
},
{
"tabLabel" : "fein",
"value" : "870142380"
},
{
"tabLabel" : "physicaladdress",
"value" : "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
]
}
}
],
"document": {
"documentId": "3",
"name": "10001000_20170803_FILE.docx",
"fileExtension": "docx",
"documentBase64": "BASE64STREAM"
}
}
],
"status": "sent",
"emailSubject": "TEST - Group Audit - 10001000"
}

Adding documents when using a template

I have created a template in my DocuSign account. As the UI requires, I have uploaded a document.
I have been trying to create a transaction using this template, however, I need to add documents to this transaction, on top of the ones provided in the template.
Looking at the DocuSign Template documentation, it doesn't seem possible as it is mentioned : To apply a template to an envelope you must set the templateId and templateRoles properties in your envelope definition. Since the template contains document(s) already you do not need to configure the documents node.
Am I missing something ?
You can use composite templates and specify a new document in addition to the documents present in the server template.
{
"compositeTemplates": [
{
"compositeTemplateId": "1",
"serverTemplates": [
{
"sequence": "1",
"templateId": "<Specify the server template Id here>"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Recipient One",
"email": "recipientone#foo.com",
"roleName": "Signer", //This is the role name in the server template
"recipientId": "1"
}
]
}
}
]
},
{
"compositeTemplateId": "2",
"inlineTemplates": [
{
"sequence": "2"
}
],
"document": {
"documentId": "3", //Make sure this documentId is different from the document's present in the server template.
"name": "DocumentThree",
"fileExtension": "txt",
"documentBase64": "RG9jIFRXTyBUV08gVFdP"
}
}
],
"emailSubject": "Adding a new doc with composite templates",
"status": "created"
}

Docusign error TAB_REFERS_TO_MISSING_DOCUMENT

This should be pretty simple. I have one composite template with 1 server template and 1 inline template with one signer. This is what the request looks like:
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "c6dc72a6-51ae-47c3-a55a-7923a247f97c "
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "Kathy Keaton",
"email": "KathyKeaton1#outlook.com",
"recipientId": "1",
"routingOrder": "1",
"roleName": "##Buyer1"
}
]
}
}
],
"document": {
"documentId": "1",
"name": "Doc1ForBigTest.docx",
"fileExtension": "docx",
"documentBase64": [bytearray]
}
}
],
"status": "sent",
"emailSubject": "Please sign the following document at 10:21 AM"
}
I want to use my copy of this particular document instead of the one in the template, but I get the TAB error mentioned above. What am I doing wrong? Thanks for any help.
You will need to download your template and look at the documentId references. It is likely that at some point the Web interface was used to update the document in the template, causing the new document to be added and the old one deleted. This involved updating the tab documentId references to be updated to "2" or higher. Now, when you substitute your document, you are specifying documentId="1" and DocuSign doesn't find a document with ID of "2" to put the tabs on.

Resources