【问题标题】:Add signer on template based docusign envelope在基于模板的文档信封上添加签名者
【发布时间】:2019-09-04 18:13:03
【问题描述】:

我创建了一个模板并添加了两个角色签名者 1 和签名者 2。我正在使用此模板创建信封并即时添加签名者。它工作正常。在某些情况下,管理员用户不知道第二个签名者并且只添加了第一个签名者并且信封是使用单个签名者创建的。一旦创建了信封,现在我想在信封上添加第二个签名者。我正在使用 C# docusign 客户端,我试过了

  {                 
     var templateInfo = await envelopesApi.ListTemplatesAsync(await AccountAsync(), envelopeId, new EnvelopesApi.ListTemplatesOptions { include = "applied" }); //fetching template id
                foreach (var template in templateInfo.Templates)
                {
                    var templateRecipients = await templatesApi.ListRecipientsAsync(await AccountAsync(), template.TemplateId, new ListRecipientsOptions { includeTabs = "true" }); //fetching tabs assigned to roles in templatea
                Var signer=  templateRecipients.Signers.FirstOrDefault(w => w.RoleName.ToLower() == signer.SigningRole.ToLower())
                    Recipients.Signers = signers.Aggregate(new List<Signer>(), (newSigners, signer) =>
                    {
                        string recipeintId = Guid.NewGuid().ToString();
                        Tabs tabs = templateSigner.Tabs;
                        Tabs newTabs = new Tabs();
                        var newSigner = new Signer
                        {
                            Email = signer.Email,
                            Name = signer.FullName,
                            RoleName = signer.SigningRole,
                            //ClientUserId = signer.Email,
                            RecipientId = recipeintId, //Int or Guid expected
                            Tabs =BuildRecipientTabs(recipeintId,signer?.Tabs) ; //copying tabs
                        };
                        newSigners.Add(newSigner);
                        return newSigners;
                    });


    var something = await envelopesApi.UpdateRecipientsAsync( AccountId, envelopeId, recipients);
}
//
         private Tabs BuildRecipientTabs(string recipientId, Tabs tabs)
        {
            Tabs newTab = new Tabs();
            if (tabs.ApproveTabs != null)
            {
                tabs.ApproveTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.CheckboxTabs != null)
            {
                tabs.CheckboxTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DateTabs != null)
            {
                tabs.DateTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DateSignedTabs != null)
            {
                tabs.DateSignedTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DeclineTabs != null)
            {
                tabs.DeclineTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EmailAddressTabs != null)
            {
                tabs.EmailAddressTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EmailTabs != null)
            {
                tabs.EmailTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EnvelopeIdTabs != null)
            {
                tabs.EnvelopeIdTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.FullNameTabs != null)
            {
                tabs.FullNameTabs.ForEach(w => { if (w!=null) { w.RecipientId = recipientId;}});             
            }
            if (tabs.FirstNameTabs != null)
            {
                tabs.FirstNameTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.FormulaTabs != null)
            {
                tabs.FormulaTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.InitialHereTabs != null)
            {
                tabs.InitialHereTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }           
            if (tabs.LastNameTabs != null)
            {
                tabs.LastNameTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.ListTabs != null)
            {
                tabs.ListTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NotarizeTabs != null)
            {
                tabs.NotarizeTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NoteTabs != null)
            {
                tabs.NoteTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NumberTabs != null)
            {
                tabs.NumberTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.PolyLineOverlayTabs != null)
            {
                tabs.PolyLineOverlayTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }           
            if (tabs.RadioGroupTabs != null)
            {
                tabs.RadioGroupTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SignerAttachmentTabs != null)
            {
                tabs.SignerAttachmentTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SignHereTabs != null)
            {
                tabs.SignHereTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; w.TabId = null; } });
            }
            if (tabs.SmartSectionTabs != null)
            {
                tabs.SmartSectionTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SsnTabs != null)
            {
                tabs.SsnTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.TitleTabs != null)
            {
                tabs.TitleTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.TextTabs != null)
            {
                tabs.TextTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId;  w.TabId=null; } });

            }
            if (tabs.TabGroups != null)
            {
                tabs.TabGroups.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }          
            if (tabs.ViewTabs != null)
            {
                tabs.ViewTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.ZipTabs != null)
            {
                tabs.ZipTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            return tabs;
        }

它添加收件人但与模板角色无关。谁能建议如何为收件人分配模板角色?

【问题讨论】:

    标签: c# docusignapi


    【解决方案1】:

    我刚刚找到了满足此要求的解决方案。未使用 UpdateRecipientsAsyncCreateRecipientsAsync 创建或更新选项卡/p>

    它使用 CreateTabAsync..

     //build recipients
                    recipients.Signers = signers.Aggregate(new List<Signer>(), (newSigners, signer) =>
                    {
                        string recipeintId = Guid.NewGuid().ToString();
                        var newSigner = new Signer
                        {
                            Email = signer.Email,
                            Name = signer.FullName,
                            RoleName = signer.SigningRole,
                            ClientUserId = signer.Email,
                            RecipientId = recipeintId //Int or Guid expected                      
                        };
                        newSigners.Add(newSigner);
                        return newSigners;
                    });
                    var addedRecipient = await envelopesApi.CreateRecipientAsync(await AccountAsync(), envelopeId, recipients); //adding recipients
                    var templateInfo = await envelopesApi.ListTemplatesAsync(await AccountAsync(), envelopeId, new EnvelopesApi.ListTemplatesOptions { include = "applied" });
    
                    //envelope is created using one template only
                        var templateRecipients = await templatesApi.ListRecipientsAsync(await AccountAsync(), templateInfo.Templates.FirstOrDefault().TemplateId, new ListRecipientsOptions { includeTabs = "true" });
                        foreach (var signer in recipients.Signers)
                        {
                            Signer templateSigner = templateRecipients.Signers.FirstOrDefault(w => w.RoleName.ToLower() == signer.RoleName.ToLower());
                            Tabs tabs =BuildRecipientTabs(signer.RecipientId, templateSigner.Tabs);
                            var t=  await envelopesApi.CreateTabsAsync(await AccountAsync(), envelopeId, signer.RecipientId, tabs);
                        }
    
    
    

    【讨论】:

      【解决方案2】:

      收件人对象包括收件人,如果您确保角色与模板中的内容匹配 - 它应该可以工作。 请分享您的整个代码以获得进一步的帮助。

      【讨论】:

      • 添加了新的签名者,但未分配我在模板中定义的签名者选项卡!!!
      • 是这个角色的标签吗?添加新签名者时是否指定了角色名称?
      • yes..对于角色 R,定义了一个包含 Sign Here 字段的选项卡。
      • 您正在复制标签,但我不确定它们是否包含对象内的所有信息。您能否检查它们是否包含收件人 ID?
      • 如果有问题,API 调用应该返回错误但它没有响应成功
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多