Search code examples
docusignapidocusigncompositetmplts

Is there a way I could control the order of the documents presented to a signer when using composite templates?


Is there a way I could control the order of the documents presented to a signer when using composite templates? If I have, for example, 3 templates that I want to send and I want the signer to see (not necessarily sign) a specific one first how would I set that. All templates only have one document. As far as I understand the sequence property for server and inline templates has more to do with the order of documents and tabs in specific composites not for the overall envelope. Here is the c# code I have for now (not perfect, kind of a first draft). I have a few template Id's stored in a list of string and I'm looping through them assigning almost random sequencing values because I only care if the inline template sequence value is higher than the server template. What I'm asking is if I have a template document that I would like to show first is there a way to do that? It doesn't have to implement looping. I just want to know if there is a way

 List<CompositeTemplate> compositeTemplates = new List<CompositeTemplate>();
            
            Recipients recipientsServerTemplate = new Recipients();
            List<Signer> signers = new List<Signer>();
            List<CarbonCopy> carbonCopies = new List<CarbonCopy>();


        List<Text> textControlsInTemplate = SetTemplateFields();
       
        Tabs tabs = new Tabs
        {
            TextTabs = textControlsInTemplate
        };

        Signer signer1 = new Signer();
        signer1.Email = signerEmail;
        signer1.Name = signerName;
        signer1.RoleName = "signer";
        signer1.RecipientId = "1";
        signer1.Tabs = tabs;
        signers.Add(signer1);

       
        CarbonCopy cc1 = new CarbonCopy();
        cc1.Email = ccEmail;
        cc1.Name = ccName;
        cc1.RoleName = "cc";
        cc1.RecipientId = "2";
        carbonCopies.Add(cc1);

        recipientsServerTemplate.Signers = signers;
        recipientsServerTemplate.CarbonCopies = carbonCopies;

      
int i = 1;
            foreach (string templateId in templateIds)
            {
                List<ServerTemplate> ServerTemplates = new List<ServerTemplate>();
                List<InlineTemplate> InlineTemplates = new List<InlineTemplate>();
                CompositeTemplate CT = new CompositeTemplate
                {
                    CompositeTemplateId = i.ToString()
                };

                ServerTemplate ST = new ServerTemplate
                {
                    Sequence = i.ToString(),
                    TemplateId = templateId
                };

                InlineTemplate IT = new InlineTemplate
                {
                    Recipients = recipientsServerTemplate,
                    Sequence = (i+1).ToString()
                };
                
                InlineTemplates.Add(IT);
                ServerTemplates.Add(ST);
                CT.ServerTemplates = ServerTemplates;
                CT.InlineTemplates = InlineTemplates;
                compositeTemplates.Add(CT);
                
                i++;


               }

EnvelopeDefinition env = new EnvelopeDefinition
            {
                Status = "sent",
                CompositeTemplates = compositeTemplates
            };

Solution

  • Assuming each server template contains one document, the composite template with the lowest sequence number should show its template's document first.

    If the sequence number doesn't work, then change the order of the composite template items within the array. Note that the envelope definition's compositeTemplates attribute takes an array of composite template objects.

    I suggest that you first use the API Request Builder to try out the sequencing. The tool can then be used to generate the matching C# code.

    Here's a live example with one server template used twice in an envelope. You can easily modify the diagram to use two different server templates.

    Blog post about composite templates