I have a template stored in Docusign with some tabs using Pre-fill Tools.
I am able to fetch the TemplateTabs using the DocuSign SDK
Tabs dsTabs = TemplatesApi.GetDocumentTabs(DSAccountId, DSTemplateId).
The above DocuSign SDK will give me all the Tabs. The PrefillTabs can be accessed using dsTabs.PrefillTabs
Since PrefillTabs are not specific to any recipient, how can I set value to those Prefilltabs and send the template for eSignature using the EnvelopeApi.CreateEnvelope(DSAccountId, envelopeDefinition)
?
For Example, I have the Company Pre-Fill Tools positioned/added to my DocuSign Template already. How can I Pre-Fill value to SenderCompany tab and send template for eSignature?
**My Sample EnvelopeDefinition**
private EnvelopeDefinition CreateEnvelopeDefinition(string templateId)
{
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.TemplateId = templateId;
envelopeDefinition.EmailSubject = "PreFill Tabs Test Document";
envelopeDefinition.EmailBlurb = "PreFill Tabs Email Blurb for Testing";
envelopeDefinition.TemplateRoles = TemplateSigner();
envelopeDefinition.Status = "sent";
return envelopeDefinition;
}
private static List<TemplateRole> TemplateSigner()
{
List<TemplateRole> templateRoleList = new List<TemplateRole>();
TemplateRole signer1 = new TemplateRole()
{
RoleName = "Contributor",
Name = "Sample1",
Email = "sample1@test.com",
};
TemplateRole signer2 = new TemplateRole()
{
RoleName = "Payroll Manager",
Name = "Sample2",
Email = "sample2@test.com"
};
TemplateRole signer3 = new TemplateRole()
{
RoleName = "Administrator",
Name = "Sample3",
Email = "sample3@test.com"
};
templateRoleList.Add(signer1);
templateRoleList.Add(signer2);
templateRoleList.Add(signer3);
return templateRoleList;
}
private static Tabs SetPreFillTabValues()
{
SenderName fullName = new SenderName()
{
TabLabel = "Signer1Name",
Value = "Adam"
};
SenderCompany senderCompany = new SenderCompany()
{
TabLabel = "CompanyTab1",
Value = "ABC"
};
Text text1 = new Text()
{
TabLabel = "TextTab1",
Value = "Text1Val"
};
Text text2 = new Text()
{
TabLabel = "TextTab2",
Value = "Text2Val"
};
PrefillTabs prefillTabs = new PrefillTabs()
{
SenderNameTabs = new List<SenderName> { fullName },
SenderCompanyTabs = new List<SenderCompany> { senderCompany },
TextTabs = new List<Text> { text1, text2 }
};
Tabs tabs = new Tabs()
{
PrefillTabs = prefillTabs,
};
return tabs;
}
Once you have an envelope created from the template, you can do this using this code:
PrefillTabs prefillTabs = new PrefillTabs();
prefillTabs.TextTabs = new List<text>();
prefillTabs.TextTabs.Add(new Text { PageNumber = "1", DocumentId = "1", tabId = tabIdValue, Value = "MyValue" });
Tabs tabs = new Tabs();
tabs.PrefillTabs = prefillTabs;
envelopesApi.UpdateDocumentTabs(accountId, envelopeId, "1", tabs);
Note that you have to know your envelopeId
, the envelope should be in draft status (not yet sent) and that you need to find the tabId
for each tab, and getting its value to match the one that you have in your code (tabIdValue
in the code above). To do that you'll have to first create the envelope, make a call to get all tabs, and then do this update, only then you can change your envelope to "sent" status.
BTW, just making sure you're aware, you can set value of tabs that are not pre-filled tabs. Some folks confuse these tabs thinking that's the only way to pre-fill tab values.