CreateEnvelopeFromTemplates缺少模板选项卡

时间:2016-10-14 19:15:16

标签: docusignapi

我正在尝试通过从我的应用程序提供收件人姓名和电子邮件地址以及文档字节来利用DocuSign模板。使用SOAP API的C#代码:

List<DocuSignService.DocuSignWS.Recipient> RecipientList = new List<DocuSignService.DocuSignWS.Recipient>();

string templateID = string.Empty;
List<DocuSignService.DocuSignWS.TemplateReferenceRoleAssignment> roleassignlist = new List<DocuSignService.DocuSignWS.TemplateReferenceRoleAssignment>();


foreach (Element e in recipients)
{
    DocuSignService.DocuSignWS.Recipient tr = new DocuSignService.DocuSignWS.Recipient();
    tr.RoleName = Convert.ToString(e["rolename"]);
    tr.SignerName = Convert.ToString(e["name"]);
    tr.Email = Convert.ToString(e["email"]);
    tr.ID = Convert.ToString(e["id"]);
    tr.UserName = tr.SignerName;

    DocuSignService.DocuSignWS.TemplateReferenceRoleAssignment roleassign = new DocuSignService.DocuSignWS.TemplateReferenceRoleAssignment();
    roleassign.RecipientID = tr.ID;
    roleassign.RoleName = tr.RoleName;
    roleassignlist.Add(roleassign);

    RecipientList.Add(tr);
}
DocuSignService.DocuSignWS.TemplateReference templateReference = new DocuSignService.DocuSignWS.TemplateReference();
templateReference.Template = <templateID>
templateReference.Document = GetDocumentBytes();
templateReference.RoleAssignments = roleassignlist.ToArray();
DocuSignService.DocuSignWS.EnvelopeInformation envelopeInfo = new DocuSignService.DocuSignWS.EnvelopeInformation();
envelopeInfo.AccountId = credentials.dsaccountid;

client.UserName = <loginemail>
client.Password = <loginpassword>;
client.IntegratorKey = IntegratorKey;
DocuSignService.DocuSignWS.EnvelopeStatus status = client.CreateEnvelopeFromTemplates(new DocuSignService.DocuSignWS.TemplateReference[] { templateReference },
                        RecipientList.ToArray(), envelopeInfo, false);

这会创建一个包含我的文档和收件人的草稿信封,但是我的DocuSign模板被使用的唯一迹象是电子邮件主题行和电子邮件Blurb。我的收件人没有模板对其角色的路由顺序,结果信封根本没有选项卡。

我确实看到其他人遇到了这个问题,但通过指定TemplateReference的TemplateReferenceRoleAssignment属性解决了这个问题,但是一旦我开始这样做,我就看不到任何变化。

<RoleAssignments>
    <RoleAssignment>
        <RoleName>Employee</RoleName>
        <RecipientID>1</RecipientID>
    </RoleAssignment>
    <RoleAssignment>
        <RoleName>Processor</RoleName>
        <RecipientID>2</RecipientID>
    </RoleAssignment>
</RoleAssignments>
</TemplateReference>
</TemplateReferences>
<Recipients>
    <Recipient>
        <ID>1</ID>
        <UserName>signer one</UserName>
        <SignerName>signer one</SignerName>
        <Email>testemail@test.com</Email>
        <Type>Signer</Type>
        <AccessCode xsi:nil="true" />
        <RoleName>Employee</RoleName>
    </Recipient>
    <Recipient>
        <ID>2</ID>
        <UserName>signer two</UserName>
        <SignerName>signer two</SignerName>
        <Email>fakeemail@fake.com</Email>
        <Type>Signer</Type>
        <AccessCode xsi:nil="true" />
        <RoleName>Processor</RoleName>
    </Recipient>
</Recipients>

2 个答案:

答案 0 :(得分:0)

除收件人nameemail之外,您还需提供有效的模板角色名称。现有服务器模板应定义一个或多个角色,这些角色称为占位符或模板角色,要使用给定角色,您必须与roleName完全匹配(区分大小写)与模板中保存的角色。

答案 1 :(得分:0)

似乎我只需要在模板参考上设置序列:

templateReference.Sequence = "1";