0

I am trying to create the multiple document and I am getting the complete document in the envelop_definition array but when it will generate the docusign envelope then it is showing only first one.

What do I need to do it?

I am using below code for multiple documents.

$docs = array();
                    $b=1;
                    foreach ($fileArray as $key => $file) {

                    // Add a document to the envelope
                    $document = new DocuSign\eSign\Model\Document();
                    $document->setDocumentBase64(base64_encode(file_get_contents($file)));
                    $document->setName('Document '.$b);
                    $document->setDocumentId($b);
                    $document->setOrder($b);
                    $docs[] = $document;
                        # code...
                    $b++;
                    }





    $envelop_definition->setDocuments($docs);
            $envelop_definition->setTemplateRoles($all_template_roles);

            // send notification about status change 
            $envelop_definition->setEventNotification($event_notification);
            // set envelope status to "sent" to immediately send the signature request
            $envelop_definition->setStatus("sent");

$envelopeApi->createEnvelope($accountId, $envelop_definition, $options);

but getting only first document.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Nov 30 '18 at 07:49

1 Answers1

0

Your use of a templateRoles object implies that you're trying to create an envelope that uses an already created template.

If that's the case then you do not add documents to the envelope/template by using the Document model.

Instead, you composite together the documents and the document(s) in the template.

If you're adding a document to the set of documents already in the template, see eg013AddDocToTemplate.sh for a code example. The example is also available in multiple languages. PHP is in production.

If you're substituting a new document for one already in the template, see this answer.

Larry K
  • 47,808
  • 15
  • 87
  • 140