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 = 1for pdf in listdir(flattenedFolder):
if isfile(join(flattenedFolder, pdf)) and pdf[len(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 = pdf[0 : len(pdf)-4],
file_extension="pdf",
document_id = index,
order=index
)
index += 1
documents.append(document)
envelope_definition.documents = documents
Best answer by Ivan.Dinkov
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 :)
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.
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 :)
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
You can login or register as either a Docusign customer or developer. If you don’t already have a Docusign customer or developer account, you can create one for free when registering.
Join the Docusign Community by logging in with your Docusign developer or customer account credentials.
Don’t have an account? You can create a free one when registering.
Note: Partner-specific logins are not available yet. Partners should log in as either a customer or developer
Docusign Community
You can login or register as either a Docusign customer or developer. If you don’t already have a Docusign customer or developer account, you can create one for free when registering.