我创建了一个模板,并添加了两个角色signer1和signer2。我正在使用此模板创建信封并动态添加签名者。它工作正常。在某些情况下,管理员用户不知道第二个签名者,仅添加第一个签名者并使用单个签名者创建信封。一旦创建了信封,现在我想在信封上添加第二个签名者。我正在使用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;
}
它添加了收件人但与模板角色没有关联。有人可以建议如何为收件人分配模板角色吗?
答案 0 :(得分:1)
我刚刚找到了解决此问题的方法。无法使用 UpdateRecipientsAsync 或 CreateRecipientsAsync 创建或更新标签/ 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);
}
答案 1 :(得分:0)
收件人对象包括收件人,并且如果您确保角色与模板中的角色匹配,它将起作用。 请分享您的完整代码以获取进一步的帮助。