user2705063
user2705063

Reputation: 17

REST equivalent of CreateEnvelopeFromTemplates?

The SOAP method CreateEnvelopeFromTemplates takes a list of TemplateReference objects which allows me to create a 1-1 mapping of documents in my ECM system to DocuSign Templates. This has worked great up until now and has allowed me to build an envelope creation algorithm without having to know how many documents are involved in a specific use case.

SOAP however does not support the new Payment tabs. In trying to find a REST replacement for this API call I haven't been able to find a way to create an envelope where each document references a different Template. The envelopes: create method for example only allows for one templateID in the envelopeDefinition. Is there a way to port the functionality I've built over to REST?

BONUS QUESTION: Why does the DocuSign backend differentiate between SOAP and REST created envelopes when applying Templates? I didn't expect to be able to programatically create Payment tabs on an envelope with SOAP, but I'm surprised specifying a Template with Payment tabs using SOAP prevents those tabs from working.

This is my SOAP call with non-functional referencing a Template with non-functional Payment tabs:

    <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <CreateEnvelopeFromTemplates xmlns="http://www.docusign.net/API/3.0">
            <TemplateReferences>
                <TemplateReference>
                    <TemplateLocation>Server</TemplateLocation>
                    <Template>8E556CD1-D343-4C07-9401-D88B00A67671</Template>
                    <Document>
                        <ID>90267</ID>
                        <Name>DS - Template Mapping - 12/4/2017 John Payme2 (90267)</Name>
                        <PDFBytes>omitted</PDFBytes>
                        <FileExtension>pdf</FileExtension>
                    </Document>
                    <RoleAssignments>
                        <RoleAssignment>
                            <RoleName>Payer</RoleName>
                            <RecipientID>37974046</RecipientID>
                        </RoleAssignment>
                    </RoleAssignments>
                    <Sequence>1</Sequence>
                </TemplateReference>
            </TemplateReferences>
            <Recipients>
                <Recipient>
                    <ID>37974046</ID>
                    <UserName>John Payme2</UserName>
                    <Email>[email protected]</Email>
                    <Type>Signer</Type>
                    <AccessCode />
                    <RequireIDLookup>false</RequireIDLookup>
                    <RoutingOrder>1</RoutingOrder>
                    <Note/>
                    <RoleName>Payer</RoleName>
                </Recipient>
            </Recipients>
            <EnvelopeInformation>
                <AccountId>9cace92e-1384-4cf7-9b4c-a2bd70aab9a1</AccountId>
            </EnvelopeInformation>
            <ActivateEnvelope>true</ActivateEnvelope>
        </CreateEnvelopeFromTemplates>
    </soap:Body>
</soap:Envelope>

Upvotes: 0

Views: 194

Answers (2)

Amit K Bist
Amit K Bist

Reputation: 6808

Ergin responded to your primary qs, now for your Bonus qs, DocuSign will still allow you to create an envelope using SOAP API if you are using template which has Payment tabs. I don't see any issue in creating an envelope using SOAP API. I tested it, and I got the payment screen at the time of signing. Please find the SOAP Request to create an envelope with Payment's Template. It uses different operation CreateEnvelopeFromTemplatesAndForms and CompositeTemplate design pattern. You just have to set accountGuid, TemplateGuid and RoleName which is set in a template.

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
  <SOAP-ENV:Body>
    <CreateEnvelopeFromTemplatesAndForms xmlns="http://www.docusign.net/API/3.0">
      <ActivateEnvelope>true</ActivateEnvelope>
      <EnvelopeInformation>
        <AccountId>{{accountId}}</AccountId>
        <Subject>Test SOAP Subject</Subject>
        <EmailBlurb>Test SOAP Body</EmailBlurb>
      </EnvelopeInformation>
      <CompositeTemplates>
        <CompositeTemplate>
          <ServerTemplates>
            <ServerTemplate>
              <Sequence>1</Sequence>
              <TemplateID>{{TemplateId}}</TemplateID>
            </ServerTemplate>
          </ServerTemplates>
          <InlineTemplates>
            <InlineTemplate>
              <Sequence>2</Sequence>
              <Envelope>
                <AccountId>{{accountId}}</AccountId>
                <Recipients>
                  <Recipient>
                    <ID>1</ID>
                    <RoleName>Signer1</RoleName>
                    <UserName>Signer 1</UserName>
                    <Email>[email protected]</Email>
                    <Type>Signer</Type>
                  </Recipient>
                </Recipients>
              </Envelope>
            </InlineTemplate>
          </InlineTemplates>
        </CompositeTemplate>
      </CompositeTemplates>
    </CreateEnvelopeFromTemplatesAndForms>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Upvotes: 2

Ergin
Ergin

Reputation: 9356

What you are looking for is called Composite Templates in the REST API. Composite templates are a very powerful feature though they can get complex pretty quickly - using CTs you can do things like combine a template and a document in the same envelope, or combine multiple templates, etc.

One of the better resources on composite templates is the features page on Templates found in the Developer Center, which has a section for composite templates: https://www.docusign.com/developer-center/explore/features/templates#composite

There's a section in the Envelopes:create API documentation that talks about composite templates.


Example Usage:

Here's a quick sample from one of the above resources, in this example two templates are combined into one single envelope:

{
    "emailSubject": "DocuSign API - Composite Templates",
    "emailBlurb": "Composite Templates Sample 1",
    "status": "sent",
    "compositeTemplates": [{
        "serverTemplates": [{
            "sequence": "1",
            "templateId": "55A80182-2E9F-435D-9B16-FD1E1C0F9D74"
        }],
        "inlineTemplates": [{
            "sequence": "1",
            "recipients": {
                "signers": [{
                    "email": "[email protected]",
                    "name": "John Doe",
                    "recipientId": "1",
                    "roleName": "Buyer"
                }]
            }
        }]
    }, {
        "serverTemplates": [{
            "sequence": "2",
            "templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA"
        }],
        "inlineTemplates": [{
            "sequence": "2",
            "recipients": {
                "signers": [{
                    "email": "[email protected]",
                    "name": "Sally Doe",
                    "recipientId": "1",
                    "roleName": "Seller"
                }]
            }
        }]
    }]
}

Upvotes: 1

Related Questions