【问题标题】:How do i use the same template for multiple recipients?如何为多个收件人使用相同的模板?
【发布时间】:2017-02-07 18:40:53
【问题描述】:

我按照 docusign 开发中心的“配方”从我上传的 pdf 模板发送文档。它可以工作,但它是一个工作流程,每个收件人都可以添加(和/或签名)同一个文档。

我需要能够从同一模板为收件人列表生成文档,并让他们都签名。我认为最好的方法是以编程方式为每个收件人生成模板,使用我通过代码提取的数据集填写他们的姓名和地址信息,然后将其发送给每个收件人进行签名。这是我使用的示例代码:

            string username = conf.ConfigurationManager.AppSettings["username"];
        string password = conf.ConfigurationManager.AppSettings["password"];
        string integratorKey = conf.ConfigurationManager.AppSettings["integratorKey"]; 

        // initialize client for desired environment (for production change to www)
        ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
        Configuration.Default.ApiClient = apiClient;

string username = conf.ConfigurationManager.AppSettings["username"];
        string password = conf.ConfigurationManager.AppSettings["password"];
        string integratorKey = conf.ConfigurationManager.AppSettings["integratorKey"]; 

        // initialize client for desired environment (for production change to www)
        ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
        Configuration.Default.ApiClient = apiClient;

        // configure 'X-DocuSign-Authentication' header
        string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
        Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

        // we will retrieve this from the login API call
        string accountId = null;

        /////////////////////////////////////////////////////////////////
        // STEP 1: LOGIN API        
        /////////////////////////////////////////////////////////////////

        // login call is available in the authentication api 
        AuthenticationApi authApi = new AuthenticationApi();
        LoginInformation loginInfo = authApi.Login();

        // parse the first account ID that is returned (user might belong to multiple accounts)
        accountId = loginInfo.LoginAccounts[0].AccountId;
        var baseUrl = loginInfo.LoginAccounts[0].BaseUrl;
        // Update ApiClient with the new base url from login call
        apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);

        EnvelopeDefinition envDef = new EnvelopeDefinition();
        envDef.EmailSubject = "[TEMPLATE NAME]";

        // provide a valid template ID from a template in your account
        envDef.TemplateId = "[TEMPLATE ID]";
var rolesList = new List<TemplateRole>();

        // 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 = "XXX";
        tRole.Name = "XXX";
        tRole.RoleName = "Test Role";
        rolesList.Add(tRole);
            envDef.TemplateRoles = rolesList;
        envDef.Status = "sent";
        EnvelopesApi envelopesApi = new EnvelopesApi();
        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

最初,我尝试仅恢复 TemplateRole(此处为“角色”),为每个人分配新的电子邮件地址,然后使用信封定义发送每个人,但这仍然是向每个收件人发送相同的共享文档。

如果我希望每个收件人都有自己的可签名文档,我是否必须为每个收件人创建一个模板,或者有没有我没有看到的更实用的方法?

【问题讨论】:

    标签: docusignapi


    【解决方案1】:

    我在这里有点困惑,但这是我的 2 美分:

    模板基本上是一个带有特定文档、收件人角色、选项卡和其他业务逻辑的预设信封。这个想法是重复使用相同的“模板”来生成尽可能多的信封。

    一个非常简单的用例可能是我的开源项目的贡献者的 NDA 表单:我从 NDA PDF 文档设置模板,将文档上传到 DocuSign,为多个贡献者信息添加占位符选项卡(姓名、电子邮件、日期和签名),以及收件人角色的占位符(我可以称之为贡献者)。保存模板后,我可以从我的 DocuSign 帐户中复制模板 ID,然后在 SDK 中使用它,就像您提到的那样,在循环中:

      myRecipients.forEach(function(myRecipient) {
        var rolesList = new List<TemplateRole>();
        TemplateRole tRole = new TemplateRole();
        tRole.Email = myRecipient.email;
        tRole.Name = myRecipient.name;
        tRole.RoleName = "Test Role";
        rolesList.Add(tRole);
        envDef.TemplateRoles = rolesList;
        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
        ...
      });
    

    【讨论】:

    • myRecipients 是一个什么样的对象,它来自哪里?我希望能够拥有一份电子邮件地址和姓名的列表,并能够为每个收到电子邮件签名的人生成一个 pdf。我现在这样做的方式似乎是在我设置的所有角色之间共享一个文档(“或 enevlope”),以便他们可以呼号。我需要每个人都能自己签名。
    • myRecipents 用作应包含收件人列表的数据结构的示例,您应该在某处拥有电子邮件/姓名列表吗?这个想法只是遍历这个列表。请注意,我每次都故意将 envDef.TemplatesRoles 重置为一个新列表,以便它始终包含 1 个且仅包含 1 个单个收件人数据。不要向其中添加模板角色。你应该像我一样在每次循环迭代时重置它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    相关资源
    最近更新 更多