【发布时间】: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