数据合并有问题

时间:2018-05-18 21:33:42

标签: c# docusignapi

我很难使用c#库将代码中的数据导入到模板中。

我有一个模板设置,我使用在线模板编辑工具添加了一个文本框。我正在尝试使用它的数据标签更新该文本框的值。我能得到一个c#的例子吗?

这是我当前代码的摘录:

Text name = new Text();
name.TabLabel = "Data Label";
name.Value = "My Name";
tRole.Tabs = new EnvelopeRecipientTabs();
tRole.Tabs.TextTabs = new List<Text>();
tRole.Tabs.TextTabs.Add(name);

List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };
envDef.TemplateRoles = rolesList;

我已经尝试了一些评论和问题,这就是我现在所拥有的:

C#

//define signer            
TemplateRole signer1 = new TemplateRole();
signer1.Name = "John Doe";
signer1.Email = "BOB@AOL.COM";
signer1.RoleName = "Owner";

//populate envelope object
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.TemplateId = "bd417d79-2a0b-4d76-8970-e2d18451c2f5";
envelopeDefinition.Status = "created";
envelopeDefinition.EmailSubject = "eSign";

//create text tab object
Text text1 = new Text();
text1.TabLabel = "FullName";
text1.Value = "EP";

//apply tab to signer
signer1.Tabs = new Tabs();
signer1.Tabs.TextTabs = new List<Text>();
signer1.Tabs.TextTabs.Add(text1);

//apply signer 
List<TemplateRole> templateroles = new List<TemplateRole>() { signer1 };
envelopeDefinition.TemplateRoles = templateroles;

// execute it
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = await envelopesApi.CreateEnvelopeAsync(account.accountId, envelopeDefinition);
return envelopeSummary.EnvelopeId;

JSON

POST https://demo.docusign.net:7801/restapi/v2/accounts/4794997/envelopes

TraceToken: fe59bc72-61f3-4c07-9eeb-0d53d558437a
Timestamp: 2018-05-21T18:36:48.4260253Z

Content-Length: 255
Content-Type: application/json
Connection: Keep-Alive
Accept: application/json
Host: demo.docusign.net
X-DocuSign-SDK: C#
X-DocuSign-Authentication: {"Username":"[omitted]", "Password":"[omitted]", "IntegratorKey":"[omitted]"}
x-ms-request-root-id: dba2cd44-40b5e3581ae1a62d
x-ms-request-id: |dba2cd44-40b5e3581ae1a62d.2.
Request-Id: |dba2cd44-40b5e3581ae1a62d.2.
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
x-forwarded-for: 24.1.74.183

{"emailSubject":"eSign With Payment From API","status":"created","templateId":"bd417d79-2a0b-4d76-8970-e2d18451c2f5","templateRoles":[{"email":"BOB@AOL.COM","name":"John Doe","roleName":"Owner","tabs":{"textTabs":[{"tabLabel":"FullName","value":"EP"}]}}]}
201 Created
Content-Type: application/json; charset=utf-8
X-DocuSign-TraceToken: fe59bc72-61f3-4c07-9eeb-0d53d558437a

{
  "envelopeId": "13fb444c-79cc-43bb-b6d4-3a6241c84ebc",
  "uri": "/envelopes/13fb444c-79cc-43bb-b6d4-3a6241c84ebc",
  "statusDateTime": "2018-05-21T18:36:46.9570000Z",
  "status": "created"
}

数据标签https://i.stack.imgur.com/Lo1dx.jpg

收件人https://i.stack.imgur.com/ZtrNH.jpg

2 个答案:

答案 0 :(得分:0)

name.TabLabel属性需要与模板中使用的标签完全匹配。因此,例如,如果您的代码设置如下:

tagger

你会使用name.TabLabel = "Text1";。设置name.Value = "My Name";然后会使用“我的名字”填充该标记,假设您的模板被引用并且您的签名者已映射到模板角色。

从填充了标签的模板发送的代码示例如下。这假定签名者角色名称是&#34;签名者1&#34;标签标签是&#34;文字1&#34;

        //define signer            
        TemplateRole signer1 = new TemplateRole();
        signer1.Name = "Example User";
        signer1.Email = "user@example.com";
        signer1.RoleName = "Signer 1";

        //populate envelope object
        EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
        envelopeDefinition.TemplateId = "xxx-yyy-zzz"; // Replace with template ID
        envelopeDefinition.Status = "created"; //generates draft instead of immediately sending

        //create text tab object
        Text text1 = new DocuSign.eSign.Model.Text();
        text1.TabLabel = "Text1";
        text1.Value = "Example Text";

        //apply tab to signer
        signer1.Tabs = new Tabs();
        signer1.Tabs.TextTabs = new List<DocuSign.eSign.Model.Text>();
        signer1.Tabs.TextTabs.Add(text1);

        //apply signer 
        List<TemplateRole> templateroles = new List<TemplateRole>() { signer1 };
        envelopeDefinition.TemplateRoles = templateroles;

        //create EnvelopesApi object
        EnvelopesApi template = new EnvelopesApi(apiClient.Configuration);

        //execute envelope generation
        EnvelopeSummary response = template.CreateEnvelope(accountId, envelopeDefinition);

答案 1 :(得分:0)

您正在created状态创建信封,并且Signer将无法查看draft信封的dataLabel值,因为签名者无法访问draft的信封} 信封。您需要创建/更新sent状态的信封,一旦签名者开始签名仪式,他/她将看到预先填充的文本选项卡值。