Populate Dropdown options using c# code in a docusign template before creating envelope

久未见 提交于 2019-12-24 09:48:19

问题


I have create a template in my Admin Account Panel, and I am using the template to create new envelopes and send to different receivers. But in my template I have a dropdown whose value changes on some condition, like for State A it will have different values, for State B it will have different values. How do I handle it programmatically. Here is how I create an envelope from a template.

        string recipientEmail = "a@a.com";
        string recipientName = "John Doe";
        string templateRoleName = "Customer";
        string TemplateId = "xxxxxxxx-c87454e95429";

        EnvelopeDefinition envDef = new EnvelopeDefinition();
        envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

        // assign recipient to template role by setting name, email, and role name.  Note that the
        // template role name must match the placeholder role name saved in your account template.  
        TemplateRole tRole = new TemplateRole();
        tRole.Email = recipientEmail;
        tRole.Name = recipientName;
        tRole.RoleName = templateRoleName;

        List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };

        // add the role to the envelope and assign valid templateId from your account
        envDef.TemplateRoles = rolesList;
        envDef.TemplateId = TemplateId;

        // set envelope status to "sent" to immediately send the signature request
        envDef.Status = "sent";

        // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
        EnvelopesApi envelopesApi = new EnvelopesApi(cfi);
       EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, envDef);

回答1:


To populate tabs in a template you must match the name of the tab using the tabLabel property and set its value to the data you want to populate it with

Documentation here

string recipientEmail = "a@a.com";
 string recipientName = "John Doe";
 string templateRoleName = "Customer";
 string TemplateId = "xxxxxxxx-c87454e95429";

 EnvelopeDefinition envDef = new EnvelopeDefinition();
 envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

// assign recipient to template role by setting name, email, and role name.  Note that the
// template role name must match the placeholder role name saved in your account template.  
var tRole = new TemplateRole();
tRole.Email = recipientEmail;
tRole.Name = recipientName;
tRole.RoleName = templateRoleName;

var dropdownItems = new List<ListItem>();

if (stateA)
{
    dropdownItems.Add(new ListItem()
    {
        Text = "Yellow", Value = "Y", Selected = "true"
    });
    dropdownItems.Add(new ListItem()
    {
        Text = "Green",Value = "G"
    });
}
else
{
    dropdownItems.Add(new ListItem()
    {
        Text = "Red", Value = "R", Selected = "true"
    });
    dropdownItems.Add(new ListItem()
    {
        Text = "Blue", Value = "B"
    });
    dropdownItems.Add(new ListItem()
    {
        Text = "Orange", Value = "O"
    });
}

tRole.Tabs = new Tabs()
{
    ListTabs = new List<List>()
    {
        new List(){
            TabLabel = "ColorDropdown",
            ListItems = dropdownItems
        }
    }
};

var rolesList = new List<TemplateRole>() { tRole };

// add the role to the envelope and assign valid templateId from your account
envDef.TemplateRoles = rolesList;
envDef.TemplateId = TemplateId;

// set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent";

// |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, envDef);


来源:https://stackoverflow.com/questions/45816142/populate-dropdown-options-using-c-sharp-code-in-a-docusign-template-before-creat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!