代码之家  ›  专栏  ›  技术社区  ›  Badri

如何使用DocuSign API/SDK在DocuSign模板中为PrefillTabs设置值?

  •  0
  • Badri  · 技术社区  · 7 月前

    我在DocuSign中存储了一个模板,其中包含一些使用预填充工具的选项卡。

    enter image description here

    我能够使用DocuSign SDK获取TemplateTabs

    Tabs dsTabs = TemplatesApi.GetDocumentTabs(DSAccountId, DSTemplateId).
    

    上述DocuSign SDK将为我提供所有选项卡。PrefillTab可以通过以下方式访问 dsTabs.PrefillTabs

    由于PrefillTabs不特定于任何收件人,我如何为这些PrefillTabs设置值,并使用 EnvelopeApi.CreateEnvelope(DSAccountId, envelopeDefinition) ?

    例如,我已经将公司预填充工具定位/添加到我的DocuSign模板中。我如何将值预填充到SenderCompany选项卡并发送电子签名模板?

    **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 = "[email protected]",                  
        };
    
        TemplateRole signer2 = new TemplateRole()
        {
            RoleName = "Payroll Manager",
            Name = "Sample2",
            Email = "[email protected]"
        };
    
        TemplateRole signer3 = new TemplateRole()
        {
            RoleName = "Administrator",
            Name = "Sample3",
            Email = "[email protected]"
        };
    
        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;
    }
    
    1 回复  |  直到 7 月前
        1
  •  1
  •   Inbar Gazit    7 月前

    一旦你从模板中创建了一个信封, 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);
    

    请注意,你必须知道你的 envelopeId ,信封应处于草稿状态(尚未发送),您需要找到 tabId 对于每个选项卡,获取其值以匹配代码中的值( tabIdValue 在上面的代码中)。为此,您必须首先创建信封,拨打电话获取所有标签,然后进行此更新,只有这样,您才能将信封更改为“已发送”状态。

    顺便说一句,只要确保您知道,您可以设置非预填充选项卡的值。有些人混淆了这些选项卡,认为这是预填充选项卡值的唯一方法。