2017-02-07 36 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單收件人數據。不要將模板角色添加到它。你應該像我一樣做,並在每次循環迭代時重置它。 –

相關問題