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.
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.
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 = "[email protected]",
Name = "Jane Doe",
RecipientId = "1",
RoleName = "Signer1",
},
new Signer()
{
Email = "[email protected]",
Name = "Bob Doe",
RecipientId = "2",
RoleName = "Signer2",
},
new Signer()
{
Email = "[email protected]",
Name = "Dan Doe",
RecipientId = "3",
RoleName = "Signer3",
}
}
}
}
}
}
}
};
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);