如何为多个收件人使用相同的模板?

时间:2017-02-07 18:40:53

标签: docusignapi

我按照"食谱"在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(&#34; trole&#34;此处),为每个人分配新的电子邮件广告,然后使用信封定义发送每个邮件,但这仍然是向每个收件人发送相同的共享文献。

因此,如果我希望他们拥有自己的可签名文档,或者是否有一种更实际的方式来实现这一目标,我是否必须为每个收件人创建一个模板?

1 个答案:

答案 0 :(得分:1)

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

模板基本上是一个预先设定的信封,包含特定文档,收件人角色,标签和其他业务逻辑。我们的想法是重复使用相同的&#34;模板&#34;生成尽可能多的信封。

一个非常简单的用例可能是我的开源项目贡献者的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);
    ...
  });