Skip to main content

I’m trying to automate sending an envelope with multiple documents attached to it. However, when the email is sent, only the 1st document is seen.

documents = =]
index = 1
for pdf in listdir(flattenedFolder):
if isfile(join(flattenedFolder, pdf)) and pdfdlen(pdf)-4 : len(pdf)] == '.pdf':
with open(join(flattenedFolder, pdf), "rb") as file:
doc_docx_bytes = file.read()
doc_b64 = base64.b64encode(doc_docx_bytes).decode("ascii")
document = Document( # create the DocuSign document object
document_base64=doc_b64,
name = pdfd0 : len(pdf)-4],
file_extension="pdf",
document_id = index,
order=index
)
index += 1
documents.append(document)
envelope_definition.documents = documents

 

Hi @kensev , without any additional info it is very hard to say if this is code issue or incorrectly build request. However, you can try to narrow down the cause by collecting and examining the API logs while creating a new envelope. 
API Request Logging

Search for the request containing the creation call. The file name should have “Create”. Examine the request and see if all docs are added. If all docs are present, please share the envelope ID so I can have a look in our logs.
Otherwise, this is code issue. You will need to debug your code and check at which point the docs are not added.

I hope this helps. 


Hello @Ivan.Dinkov ,

Thank you for replying.

I checked the logs and all the documents are there in the request.

 

I attached the request here.

The envelope id is: 0b6934d5-f9b9-42af-b801-7b0d4067ad83


Thanks, let me have a look. Please delete the logs ^
I’ll follow up by DM


Hi @kensev the cause for additional docs disappearing in the envelope is:

  • use of server template
  • use simple envelopeDefinition object 

When using the above combination, because of the simple envelopeDefinition structure only the first document from the list will replace the single server template document. Also the rest of the documents will not be added to the envelope.

To achieve your goal you need to use composite templates. They would allow for the single server doc to be replaced and at the same time add additional docs to the envelope.
However, the structure will be a bit complex.   

For example this blog post explains how to replace a single server template document.
Every additional document should be added as a single composite template object including a single doc object and inlineTemplate.
For example:
 


In the above, the first object ("compositeTemplateId": "1") will overwrite the server template doc.
Also, every inlineTemplate should be the same as below

 


I hope this clarifies a little bit the mystery around the composite templates :)

A good reads:

https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/templates/composite/
https://www.docusign.com/blog/dsdev-why-use-composite-templates
https://www.docusign.com/blog/developers/envelopes-dynamic-number-signers


Please "Select as Best" below if you find my answer is a valid solution


Hello @Ivan.Dinkov ,

Composite templates work and the documents are now being sent correctly.

However, the problem now is that it’s not applying what the template is supposed to.

For example, here’s the view of manually using the template and sending.

It’s supposed to tell the signer where to sign.

 

This is the view from automation.

 

What am I missing here?

Thank you!


Hi @kensev I’d suggest opening a case through the support center as this is turning into a how-to question.
You can reference 13439184 in your case description


Hello @Ivan.Dinkov ,

I got it to work! Turns out I was using “role_name” but it was supposed to be “roleName”.

However, there seems to be a bug. Whenever I sign, my signature is added but the yellow Sign button is still there indicating that it was not signed.

You can see that my signature and the button is overlapping.

 

As a result, I cannot finish signing the document because it still thinks that I have not yet signed.


Hi @kensev I’d suggest opening a case through the support center as this is turning into a how-to question.


Hello @Ivan.Dinkov ,

Will do. Thanks a lot for the help!


Reply