2

Using the DocuSign API in C#, I was easily able to get a test envelope through. Now I'm testing on an envelope with the following diagram.

Docusign Flow

I know I have to assign a TemplateRole for a recipient, but when I'm sending the Email, things go wrong. I assumed by defining multiple roles, each of the items in the signing order would be set up. That for whatever reason does not happen, and instead I get two documents sent out. Depending on what TemplateRoles I include, dummy data will get inserted for the sender name/address as well. I'd like to prevent that.

EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Sample Signature Request";

envDef.TemplateId = TemplateID;

TemplateRole DirectorRole = new TemplateRole();
DirectorRole.Email = RecipientEmail;
DirectorRole.Name = RecipientName;
DirectorRole.RoleName = "Director";

TemplateRole TraineeRole = new TemplateRole();
TraineeRole.Email = RecipientEmail;
TraineeRole.Name = "A Trainee";
TraineeRole.RoleName = "Trainee";

List<TemplateRole> rolesList = new List<TemplateRole>() { DirectorRole, TraineeRole };
envDef.TemplateRoles = rolesList;

envDef.Status = "sent";
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

You can see I have the option to send to a bulk recipient or individual. I'd like to send to either one or the other. How can I go about doing so? Here's my current code. General examples of how to assign different types of roles would be appreciated since as far as I know, there's not a whole lot of C# example code out there.

Larry K
  • 47,808
  • 15
  • 87
  • 140
lloyd
  • 1,089
  • 1
  • 17
  • 39

2 Answers2

1

Please show your complete code for creating the envDef object. Are you setting the template ID?

The RoleName for each TemplateRole object must exactly match the role name in the template.

Each Role defined by the Template must be set. If you decide that you want to start with a Template and then modify it to remove a role, I believe that's possible but you'd need to do it by using composite templates. Instead, I'd recommend you consider having two templates, one with the two roles, one with a single role.

Re sending to a bulk recipient. I'd ask that as a separate question. I suggest you use stepwise-refinement. First get your envelopes working with role substitution.

Then move on to the different question of sending out many different envelopes controlled by a CSV file (bulk send).

Larry K
  • 47,808
  • 15
  • 87
  • 140
  • So you're suggesting removing either the bulk send or the individual recipient, and separating them into two separate templates? It seems like that could be causing the issue as far as I can tell. I'd just have to get an admin to change the templates. The role names do match, but I was under the assumption that I could omit the bulk send for example to take a different route for a single individual, but I guess this is not the case. – lloyd Jun 29 '17 at 15:38
  • Sorry if I wasn't clear. I'm suggesting that you first get the template working without the bulk recipient. Then ask a different question on StackOverflow about using a bulk recipient with a template. Bulk recipients require uploading the CSV file, etc. -- they're a different kettle of fish. – Larry K Jun 30 '17 at 05:05
  • I absolutely got what you meant. Your post was of use for sure. It pointed me in the right direction, and I eventually figured out about the CSV being mandatory even with the diagram that I gave, but I needed more information about template roles as well just to make things clear because C# examples are not particularly easy to find. – lloyd Jun 30 '17 at 16:01
1

You can use the DocuSign compositeTemplates feature and create envelopes from templates. This is more flexible than using TemplateRole.

See this sample code for creating envelope from a template. It is using the DocuSign C# SDK

      string accountId = Init();


        var envDef = new EnvelopeDefinition()
        {
            EmailSubject = "Envelope with multiple recipient roles",
            Status = "sent",
            CompositeTemplates = new List<CompositeTemplate>()
            {
                new CompositeTemplate()
                {
                    ServerTemplates = new List<ServerTemplate>()
                    {
                        new ServerTemplate()
                        {
                            TemplateId = "", //CreateTemplate()
                            Sequence = "1"
                        }
                    },
                    InlineTemplates = new List<InlineTemplate>()
                    {
                        new InlineTemplate()
                        {
                            Sequence = "1",
                            Recipients = new Recipients()
                            {
                                Signers = new List<Signer>()
                                {
                                    new Signer()
                                    {
                                        Email = "Janedoe@acme.com",
                                        Name = "Jane Doe",
                                        RecipientId = "1",
                                        RoleName = "Signer1",
                                    },
                                    new Signer()
                                    {
                                        Email = "Bobdoe@acme.com",
                                        Name = "Bob Doe",
                                        RecipientId = "2",
                                        RoleName = "Signer2",
                                    },
                                    new Signer()
                                    {
                                        Email = "DanDoe@acme.com",
                                        Name = "Dan Doe",
                                        RecipientId = "3",
                                        RoleName = "Signer3",
                                    }

                                }
                            }
                        }
                    }
                }
            }
        };


        EnvelopesApi envelopesApi = new EnvelopesApi();
        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43
  • 1
    Just to clarify for any others who might be asking the same question, both methods using either `CompositeTemplate` or `TemplateRole` work without the bulk sender in my template. For now I've removed the bulk send option. The flexibility of `CompositeTemplate` is very useful. I will move to a different discussion about implementing bulk sending should issues continue. – lloyd Jun 29 '17 at 18:14