Reputation: 5323
I have a template in Docusign that I need to send to [email protected]
However Joe is responsible for managing 10 clients and instead of me sending Joe 10 separate envelopes for him to sign I want to send Joe 1 envelope with 10 documents and Joe needs to sign all 10 document in the envelope. The documents are identical except for the different data filled in the text field of the template
I am using the C# SDK provided by Docusign and I can send one document in an envelope using EnvelopeDefinition
class and TemplateRole
class but am lost as to how to create 10 documents in an envelope
The following recipe does it but it is in python and uses the REST API with which I am not sure how to translate to the C# SDK equivalent https://www.docusign.com/developer-center/recipes/send-multiple-docs
Upvotes: 1
Views: 1461
Reputation: 7383
You can use compositeTemplates and reuse the same server template multiple times in the envelope. The below code uses the same server Template and repeats it 10 times in the envelope. See full example here
public void CreateEnvelope()
{
var envDef = new EnvelopeDefinition()
{
EmailSubject = "Envelope with multiple documents",
Status = "sent",
CompositeTemplates = new List<CompositeTemplate>()
};
for (int docNumber = 1; docNumber <= 10; docNumber++)
{
var compostiteTemplate = BuildCompositeTemplate(docNumber.ToString());
envDef.CompositeTemplates.Add(compostiteTemplate);
}
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Console.WriteLine(envelopeSummary);
}
public CompositeTemplate BuildCompositeTemplate(string docNumber)
{
string serverTemplateId = "";//Add your server template ID here
return new CompositeTemplate()
{
ServerTemplates = new List<ServerTemplate>()
{
new ServerTemplate()
{
TemplateId = serverTemplateId,
Sequence = docNumber
}
},
InlineTemplates = new List<InlineTemplate>()
{
new InlineTemplate()
{
Sequence = docNumber,
Recipients = new Recipients()
{
Signers = new List<Signer>()
{
new Signer()
{
Email = "[email protected]",
Name = "Jane Doe",
RecipientId = "1",
RoleName = "Signer1",
Tabs = new Tabs()
{
TextTabs = new List<Text>()
{
new Text()
{
DocumentId = docNumber,
PageNumber = "1",
XPosition = "100",
YPosition = "100",
Width = 120,
Value = "Some Tab Value " + docNumber
}
}
}
}
}
}
}
}
}
}
Upvotes: 4
Reputation: 83
There is the property Documents in the class EnvelopeDefinition, where you can add multiply documents.
I use the REST API Explorer from DocuSign when I want to check how to implement a feature.
enDef = new EnvelopeDefinition();
doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(System.IO.File.ReadAllBytes(filename));
doc.Name = DocName;
doc.DocumentId = "1"; // increment this
enDef.Documents = new List<Document>();
enDef.Documents.Add(doc);
Added
For multiply template roles also exists a property called TemplateRoles in the EnvelopeDefinition. There you can add more than one.
tempRole = new TemplateRole();
tempRole.Name = Rolename;
enDef.TemplateRoles = new List<TemplateRole>();
enDef.TemplateRoles.Add(tempRole);`
Upvotes: 1