在创建信封之前,使用docusign模板中的c#代码填充下拉选项

时间:2017-08-22 11:16:24

标签: docusignapi

我在管理员帐户面板中创建了一个模板,我正在使用该模板创建新的信封并发送给不同的接收者。 但在我的模板中,我有一个下拉列表,其值在某些条件下会发生变化, 对于状态A,它将具有不同的值,对于状态B,它将具有不同的值。 我如何以编程方式处理它。 以下是我如何使用模板创建信封。

        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 个答案:

答案 0 :(得分:2)

  

要填充模板中的标签页,您必须使用 tabLabel 属性匹配标签名称,并将其值设置为要使用

填充标签的数据

文档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);
相关问题