I am creating envelopes from a template. I need to know the documentIds that will be created in the envelope ahead of time so I can deal with a strange special case prefilling radio buttons. (I can explain why in more detail, but it's not really relevant to this question.)
So where do these document IDs come from? I am using the REST api for all of this.
This is my template:
GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/templates/78b351c5-84f8-49c9-af48-redacted
{
"envelopeTemplateDefinition": {
"templateId": "78b351c5-84f8-49c9-af48-redacted",
"name": "my dev template",
.... truncated for brevity ....
},
"documents": [
{
"documentId": "73370178",
"uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/73370178",
"name": "DS_Testing_Doc1.pdf",
"order": "1",
"pages": "1"
},
{
"documentId": "13535052",
"uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/13535052",
"name": "DS_Testing_Doc2.pdf",
"order": "2",
"pages": "1"
}
],
"recipients": {
.... truncated for brevity ....
}
}
This is my Create Envelope from Template call:
POST https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/
{ "envelopeId":null,
"accountId":"redacted",
"templateId":"78b351c5-84f8-49c9-af48-redacted",
"status":"sent",
"templateRoles":[
{
"id":null,
"roleName":"producer",
"email":"myemail#mycompany.com",
"name":"Eric",
"clientUserId":"",
"status":"sent",
"tabs":{
.... truncated for brevity ....
}
},
{
"id":null,
"roleName":"hidden",
"email":"myemail2#mycompany.com",
"name":"My Agent",
"clientUserId":"",
"status":"created",
"tabs":{
.... truncated for brevity ....
}
}
],
"voidedReason":null
}
Response from creating envelope:
{
"envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted",
"statusDateTime": "2016-01-26T20:41:59.2400000Z",
"status": "sent"
}
Now get the details about Documents in the envelope:
GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents
{
"envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
"envelopeDocuments": [
{
"documentId": "1",
"name": "DS_Testing_Doc1.pdf",
"type": "content",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/1",
"order": "1",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
},
{
"documentId": "2",
"name": "DS_Testing_Doc2.pdf",
"type": "content",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/2",
"order": "2",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
},
{
"documentId": "certificate",
"name": "Summary",
"type": "summary",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/certificate",
"order": "999",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
}
]
}
In the final call where I view details about Documents in the Envelope, the IDs are "1" and "2". However, in my template, the documentIDs are "73370178" and "13535052".
So, how do documentIds get assigned when creating an Envelope from a template? Do they correspond to 'order' in the template, as they appear to? Can I rely on them always starting at 1 incrementing from there?
Is it possible to define the documentIds in my template and have them be the same when I create an Envelope?
Is it possible to assign the documentIds when creating the envelope from the template (assuming the PDF is uploaded to the template, not sending the whole PDF byte stream)?
Cheers
The documentId is actually completely up to you - it's a client defined value and takes a string so really you can use any naming standard you want (i.e. numbers, letters, or a combo). Many integrations use simple numbers (1, 2, 3, etc.) for the documentIds whereas others others use strings or other identifiers.
In any case, you just need to remember what value you set for a given a document if you want to later assign a radio tab to a recipient of that document.
Note: If you do NOT provide a documentId when creating an envelope the system will automatically generate and assign an GUID as the documentId, you can then make the Get Documents API call to retrieve that ID.
Related
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
I need some help to identify how to send Document Custom Fields' values at the stage of creating an envelope. Below is the workflow:
Create the Document Custom Fields (account specific) with name, type and initial value through API (POST [BaseURI]/tab_definitions)
Create a template with document through API and place the required Document Custom Fields in the document through DocuSign UI
Create an envelope and send specific values for the Document Custom Fields through API (POST [BaseURI]/envelopes)
Creating an envelope is working fine referring (https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create). I have tried sending the values through:
document -> documentFields
customFields -> textCustomFields
{
"templateId": "51234567-1244-1234-1234-12345a857203",
"templateRoles": [
{
"roleName": "Role1",
"name": "Jane Doe",
"email": "jane#doe.com"
},
{
"roleName": "Role2",
"name": "John Doe",
"email": "john#doe.com"
}
],
"customFields": {
"textCustomFields": [
{
"name": "Account.Name",
"value": "account-name1234"
},
{
"name": "Candidate.FullName",
"value": "candidate-name1234"
},
{
"name": "Candidate.Mobile",
"value": "0412345678"
}
]
},
"status": "sent"
}
The CustomFields parameter is for Envelope Custom Fields. If you want to define tag values for a recipient, the tag parameters should be nested under the TemplateRole. You'll also want to use the tabLabel parameter to identify tabs instead of the name. Finally, make sure your Role Names and TabLabels match exactly between your template and your API call. Try this:
{
"templateId": "51234567-1244-1234-1234-12345a857203",
"templateRoles": [
{
"roleName": "Role1",
"name": "Jane Doe",
"email": "jane#doe.com"
"tabs": {
"TextTabs": [
{
"tabLabel": "Account.Number",
"value": "00000000"
},
{
"tabLabel": "Account.Name",
"value":"ExampleAccount"
}
],
},
{
"roleName": "Role2",
"name": "John Doe",
"email": "john#doe.com"
}
],
"status": "sent"
}
Finally, you may want to consider using a Composite Template instead of the basic Envelope Creation call. Details as to why are available here: https://www.docusign.com/blog/dsdev-why-use-composite-templates/
What I want is to place the custom fields at document level while creating the template so that later I can have unique values for every envelope that is created. These values should be visible to all the recipients.
These are the steps that I currently follow:
Create Document Custom Fields/Tab Definitions at the Account level.
Create the template from our app and navigate to DocuSign to place the above created custom fields on the document (it is signer specific).
Save the template.
At a later stage, choose the template in our app and create an envelope with the template ID, templateRoles (with custom fields' values for signer), status etc. like below:
{
"templateId": "1e6c1118-1234-1244-1244-c4a11111775b",
"templateRoles": [
{
"roleName": "Signer1",
"name": "Signer1",
"email": "Signer1#Signer1.com",
"tabs": {
"textTabs": [
{
"tabLabel": "Account.Name",
"value": "account-name777"
},
{
"tabLabel": "Candidate.FullName",
"value": "candidate-name1234"
},
{
"tabLabel": "Candidate.Mobile",
"value": "0412347777"
}
]
}
},
{
"roleName": "Signer2",
"name": "Signer2",
"email": "Signer2#Signer2.com",
"tabs": {
"textTabs": [
{
"tabLabel": "Account.Name",
"value": "account-name777"
},
{
"tabLabel": "Candidate.FullName",
"value": "candidate-name1234"
},
{
"tabLabel": "Candidate.Mobile",
"value": "0412347777"
}
]
}
}
],
"status": "sent"
}
The above works for Signer1 but does not show the custom fields' values to Signer2. The custom fields need to be exactly the same for all recipients. Is there a way to achieve this?
Also what I noticed was after Signer1 signs the document then the custom fields' values show to Signer2.
Change the tabLabels so they are not the same, here is the code:
{
"templateId": "1e6c1118-1234-1244-1244-c4a11111775b",
"templateRoles": [
{
"roleName": "Signer1",
"name": "Signer1",
"email": "Signer1#Signer1.com",
"tabs": {
"textTabs": [
{
"tabLabel": "Account.Name1",
"value": "account-name777"
},
{
"tabLabel": "Candidate.FullName1",
"value": "candidate-name1234"
},
{
"tabLabel": "Candidate.Mobile1",
"value": "0412347777"
}
]
}
},
{
"roleName": "Signer2",
"name": "Signer2",
"email": "Signer2#Signer2.com",
"tabs": {
"textTabs": [
{
"tabLabel": "Account.Name2",
"value": "account-name777"
},
{
"tabLabel": "Candidate.FullName2",
"value": "candidate-name1234"
},
{
"tabLabel": "Candidate.Mobile2",
"value": "0412347777"
}
]
}
}
],
"status": "sent"
}
I know that I can do the following using PDF field transform and a composite template (I'm actually using the C# SDK so the actually JSON isn't as important as knowing this is possible using the SDK) to have a recipient sign all signature tabs on a PDF form (not a DocuSign template) whose names start with PrimarySigner
"tabs":{
"signHereTabs":[
{
"tabLabel":"PrimarySigner\\*"
}
]
Suppose that a document has three sets of signature fields. Signer one gets PrimarySigner, Signer two gets SecondarySigner and depending on the context of the envelope Signer one or Signer two might get TertiarySigner. In the case of Signer one getting those signature fields can I add multiple wildcards for a signer? e.g. :
"tabs":{
"signHereTabs":[
{
"tabLabel":"PrimarySigner\\*"
}
],
"signHereTabs":[
{
"tabLabel":"TertiarySigner\\*"
}
]
}
UPDATE: I've implemented this, I thought, using the C# SDK. However, the signature tags are just disappearing for both signers; when they view the documents they are getting the free form rather than the directed signing experience. The PDF document I'm sending has two PDF signature fields named DocuSignSignHere_Signer1_1 and DocuSignSignHere_Signer2_1. I've double checked the obvious such as setting TransformPDFFields, etc. Wildcards will be respected on either end of the pdf form field names, yes?
Here is the JSON of the serialized envelope.
{
"compositeTemplates":[
{
"inlineTemplates":[
{
"documents":[
{
"documentBase64":"redacted",
"documentId":"1",
"name":"TestPDFForm.pdf",
"transformPdfFields":"true"
}
],
"recipients":{
"signers":[
{
"email":"test#test.com",
"name":"Test Signer 1",
"recipientId":"1",
"tabs":{
"signHereTabs":[
{
"tabLabel":"DocuSignSignHere_Signer1\\*"
}
]
}
},
{
"email":"test2#test.com",
"name":"Test Signer 2",
"recipientId":"2",
"tabs":{
"signHereTabs":[
{
"tabLabel":"DocuSignSignHere_Signer2\\*"
}
]
}
}
]
},
"sequence":"1"
}
]
}
],
"customFields":{
"textCustomFields":[
{
"name":"ClientId",
"value":"A:1!!D:1!!T:1!!UserId:123!!C:10BD32B131C5ECE3"
}
]
},
"documents":[
],
"emailSubject":"Test Email",
"eventNotification":{
"envelopeEvents":[
{
"envelopeEventStatusCode":"completed"
}
],
"includeCertificateOfCompletion":"true",
"includeCertificateWithSoap":"false",
"includeDocumentFields":"true",
"includeSenderAccountAsCustomField":"true",
"includeTimeZone":"true",
"requireAcknowledgment":"true",
"signMessageWithX509Cert":"false",
"url":"https://test.test.com/documentcallback.aspx",
"useSoapInterface":"false"
},
"status":"sent"
}
Yes you can assign multiple fields with WildCards to a single Signer.
In your example, you should move the wild card prefix (\\*) at the beginning of the tabLabel. Also you can move the signHereTabs into a single array.
Here is a sample PostEnvelope request. See full example here
POST /v2/accounts/{accountId}/envelopes
{
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Jane Doe",
"email": "janedoe#acme.com",
"recipientId": "1",
"tabs": {
"signHereTabs": [
{
"tabLabel": "\\*PrimarySigner"
},
{
"tabLabel": "\\*TertiarySigner"
}
]
}
},
{
"name": "Bob Doe",
"email": "BobDoe#acme.com",
"recipientId": "2",
"tabs": {
"signHereTabs": [
{
"tabLabel": "\\*SecondarySigner"
}
]
}
}
]
}
}
],
"document": {
"documentId": "1",
"name": "Doc with Fields",
"transformPdfFields": "true",
"fileExtension": "pdf",
"documentBase64": ""
}
}
],
"emailSubject": "Doc with form fields",
"status": "sent",
}
I am trying to use the docusign-node-client to send an envelope using the createEnvelope class. This class sends a REST API request to the /envelopes endpoint. The envelope I am trying to send contains a Composite Template.
Here is the body I am attempting to send to docusign
{
"emailSubject": "Sent from Node SDK",
"emailBlurb": "Email body here",
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentBase64": "base64StringHere",
"documentId": "1",
"fileExtension": ".pdf",
"name": "filename.pdf"
}
],
"envelope": {
"emailBlurb": "Email body here",
"emailSubject": "Sent from Node SDK",
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"recipients": {
"signers": [
{
"email": "myEmail#domain.com",
"name": "My Name",
"recipientId": "1"
}
]
}
}
}
],
"serverTemplates": [
{
"sequence": "1"
}
]
}
],
"status": "sent"
}
When I send this body I get the following error: "The request contained at least one invalid parameter. Invalid value specified for \'templateId\' in composite template sequence: 1"
If I remove the serverTemplates array, I get this error: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line."
If I include a valid templateId in the serverTemplate object it creates an envelope successfully.
The as is application I am converting to Node JS used the Docusign SOAP API and is able to send composite templates with 1 to many documents. Each of these documents can be associated to their own document template or no docusign template.
Does docusign not accept composite templates without some sort of reference to a template id?
You are specifying the inlineTemplate.envelope property incorrectly. You can define the recipients and custom fields directly within the inlineTemplate. You do not have to specify the emailSubject/emailBlurb within the inlineTemplate.
Also note that the custom fields specified at the root level will be ignored when using composite templates. See this answer
The following json should work for you.
{
"emailSubject": "Sent from Node SDK",
"emailBlurb": "Email body here",
"status": "sent"
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentBase64": "base64StringHere",
"documentId": "1",
"fileExtension": ".pdf",
"name": "filename.pdf"
}
],
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"recipients": {
"signers": [
{
"email": "myEmail#domain.com",
"name": "My Name",
"recipientId": "1"
}
]
}
}
]
}
]
}