2017-02-07 35 views
0

我遵循docusign开发中心的“配方”,从我上传的pdf模板发送文档。它可以工作,但是每个收件人都可以添加(和/或签署)同一个文档。如何为多个收件人使用相同的模板?

我需要能够生成文件形成的收件人列表相同的模板,并让他们都签字。我想要做到这一点的最好方法是以编程方式为每个收件人生成模板,使用我通过代码插入的数据集填写他们的名称和地址信息,然后将其发送给每个收件人进行签名。这是示例代码我TREID有:

  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); 

最初,我尝试了reinstatiating的TemplateRole(“trole”在这里),为每一个assiging新的电子邮件addessses,然后用信封定义发送的每一个,但仍然向每个收件人发送相同的共享文档。

所以我必须为每一个收件人模板,如果我希望他们有自己的签名文档或有没有这样做,我不是看的更实际的方法是什么?

回答

1

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

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

一个非常简单的用例可能是我的开源项目贡献者的NDA表单:我从NDA PDF文档设置了一个模板,将文档上传到DocuSign,为几个贡献者信息添加了占位符标签(名称,电子邮件,日期和签名)以及收件人角色的占位符(我可以称其为贡献者)。一旦保存我的模板,我可以从我的DocuSign帐户复制的模板编号,并用它在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); 
    ... 
    }); 
+0

什么样的对象是myRecipients和它从何而来?我希望能够列出电子邮件地址和姓名,并且能够为每个可以获得电子邮件签名的人生成PDF。我现在这样做的方式似乎是在我设置的所有角色之间共享一个文档(“或enevlope”),以便他们可以调用签名。我需要每个人都能够签署他们自己的。 – user609926

+0

myRecipe用作应包含收件人列表的数据结构的示例,您应该在某处有电子邮件/名称列表吗?这个想法只是循环访问这个列表。 请注意,我故意每次都重新设置envDef.TemplatesRoles到一个新的列表,所以它总是包含1个,只有1单收件人数据。不要将模板角色添加到它。你应该像我一样做,并在每次循环迭代时重置它。 –

相关问题