简体   繁体   English

DocuSign API-UpdateTabs不在文档中设置值

[英]DocuSign API - UpdateTabs not setting values in document

I'm working in the sandbox and have a template saved with a PDF that I've created fields for. 我正在沙盒中工作,并保存了一个模板,该模板与我为其创建字段的PDF一起保存。 I'm trying to pre-fill these fields based on some conditions, and then send the template out to be signed. 我正在尝试根据某些条件预填充这些字段,然后将模板发送出去以进行签名。 I'm using the UpdateTabs method and passing in a list of the tabs for the template, including the TabId, which I've looped through and changed the value for. 我正在使用UpdateTabs方法,并传入模板的选项卡列表,包括TabId,我已对其进行遍历并更改了其值。

When the template gets sent after this, the fields are all blank. 此后发送模板时,所有字段均为空白。 Is this a limitation of the sandbox environment, or am I doing this incorrectly? 这是沙箱环境的限制,还是我做错了?

Here's the code for creating the template draft, grabbing the tabs, updating the tabs, then sending the draft: 以下是用于创建模板草稿,抓取标签,更新标签并发送草稿的代码:

var roles = recipients
    .Select((role, i) =>
    {
        var templateRole = role.MapTo<TemplateRole>();
        templateRole.RoutingOrder = $"{i + 1}";
        return templateRole;
    })
    .ToList();

var envelope = new EnvelopeDefinition(
    TemplateId: templateId,
    TemplateRoles: roles,
    Status: DocuSignConstants.Statuses.Created);

var envelopeApi = new EnvelopesApi(_docuSignClient.Client.Configuration);

var result = await envelopeApi
    .CreateEnvelopeAsync(_docuSignContext.Account.AccountId, envelope)
    .ConfigureAwait(false);

var template = await GetDocuSignTemplateById(templateId);

// Grabbing the tabs from the template and then updating the values in them
var tabs = await GetDocumentTabs(templateId, template.Documents.First().DocumentId);
SetDocumentTabValues(recordId, templateId, template.Documents.First().DocumentId, tabs);

var draftRecipients = await envelopeApi.ListRecipientsAsync(_docuSignContext.Account.AccountId,
    result.EnvelopeId);

foreach (var signer in draftRecipients.Signers)
{
    envelopeApi.UpdateTabs
    (
        _docuSignContext.Account.AccountId,
        result.EnvelopeId,
        signer.RecipientId,
        tabs
    );
}

envelopeApi.Update(_docuSignContext.Account.AccountId, result.EnvelopeId, new Envelope
{
    Status = DocuSignConstants.Statuses.Sent
});

And here's where I'm setting the value for the tabs (text tabs in this case): 这是我在其中设置标签(在这种情况下为文本标签)的值的地方:

var tab = tabs.TextTabs?.FirstOrDefault(x => x.TabLabel == field.TemplateField);
if (tab != null)
{
    tab.OriginalValue = fieldValue;
    tab.Value = fieldValue;
}

I tried setting both the Value and the OriginalValue fields, but neither of them sets the fields. 我尝试同时设置“值”和“原始值”字段,但是它们都不设置字段。 It comes in blank with a warning in the upper right saying "DEMONSTRATION DOCUMENT ONLY", which makes me wonder if I just can't set the tabs in the sandbox. 它是空白的,右上方有一个警告,上面写着“仅演示文档”,这使我想知道是否无法在沙箱中设置选项卡。

退回文件

I figured out the issue: I was grabbing the tabs from the template's documents instead of calling the ListTabs function on each recipient. 我发现了问题:我从模板文档中获取选项卡,而不是在每个收件人上调用ListTabs函数。 Once I grabbed those tabs instead, setting the values works perfectly. 一旦我抓住了这些选项卡,就可以完美地设置值。

foreach (var signer in draftRecipients.Signers)
{
    var signerTabs = await envelopeApi
        .ListTabsAsync(_docuSignContext.Account.AccountId, 
        result.EnvelopeId, 
        signer.RecipientId);

    SetDocumentTabValues(recordId, templateId, template.Documents.First().DocumentId, signerTabs);

    envelopeApi.UpdateTabs
    (
        _docuSignContext.Account.AccountId,
        result.EnvelopeId,
        signer.RecipientId,
        signerTabs
    );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM