如何从docusign api生成自动填充的模板

问题描述 投票:0回答:1

我已经在沙箱中设置了模板。每当我想重定向到demo.docusign.net并在PDF上执行操作时,它都会自动填充选项卡。但是我的要求是简单地生成PDF,而无需单击按钮即可重定向到docusign。我要通过单击按钮进行用户发送来发送用户信息,它必须在PDF上生成自动填充的客户数据以供查看(草稿版本)。当前,即使我传递值,它也会在没有任何动态用户数据的情况下生成模板。如果有执行此操作的任何api,请告诉我。

预先感谢

docusignapi
1个回答
0
投票

我不完全确定我了解您要做什么。但是听起来像您想要的:

1. Remote signing. Not Embedded Signing.

2. Populate values of tabs in templates.

您也没有指定使用的编码语言,所以我将给您一些C#。您可以在上面的链接中的所有lang中找到完整的代码示例。

        // Step 1: Obtain your OAuth token
        var accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN}
        var accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

        // Step 2: Construct your API headers
        var config = new Configuration(new ApiClient(basePath));
        config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

        // Step 3: Create Tabs and CustomFields
        // Set the values for the fields in the template
        // List item
        List colorPicker = new List
        {
            Value = "green",
            DocumentId = "1",
            PageNumber = "1",
            TabLabel = "list"
        };

        // Checkboxes
        Checkbox ckAuthorization = new Checkbox
        {
            TabLabel = "ckAuthorization",
            Selected = "true"
        };
         Checkbox ckAgreement = new Checkbox
        {
            TabLabel = "ckAgreement",
            Selected = "true"
        };

        RadioGroup radioGroup = new RadioGroup
        {
            GroupName = "radio1",
            // You only need to provide the readio entry for the entry you're selecting
            Radios = new List<Radio> { new Radio { Value = "white", Selected = "true" } }
        };

        Text includedOnTemplate = new Text
        {
            TabLabel = "text",
            Value = "Jabberywocky!"
        };

        // We can also add a new tab (field) to the ones already in the template
        Text addedField = new Text
        {
            DocumentId = "1",
            PageNumber = "1",
            XPosition = "280",
            YPosition = "172",
            Font = "helvetica",
            FontSize = "size14",
            TabLabel = "added text field",
            Height = "23",
            Width = "84",
            Required = "false",
            Bold = "true",
            Value = signerName,
            Locked = "false",
            TabId = "name"
        };

        // Add the tabs model (including the SignHere tab) to the signer.
        // The Tabs object wants arrays of the different field/tab types
        // Tabs are set per recipient/signer
        Tabs tabs = new Tabs
        {
            CheckboxTabs = new List<Checkbox> { ckAuthorization, ckAgreement },
            RadioGroupTabs = new List<RadioGroup> { radioGroup },
            TextTabs = new List<Text> { includedOnTemplate, addedField },
            ListTabs = new List<List> { colorPicker }
        };

        // Create a signer recipient to sign the document, identified by name and email
        // We're setting the parameters via the object creation
        TemplateRole signer = new TemplateRole
        {
            Email = signerEmail,
            Name = signerName,
            RoleName = "signer",
            Tabs = tabs //Set tab values
        };

        TemplateRole cc = new TemplateRole
        {
            Email = ccEmail,
            Name = ccName,
            RoleName = "cc"
        };

        // Create an envelope custom field to save our application's
        // data about the envelope
        TextCustomField customField = new TextCustomField
        {
            Name = "app metadata item",
            Required = "false",
            Show = "true", // Yes, include in the CoC
            Value = "1234567"
        };

        CustomFields cf = new CustomFields
        {
            TextCustomFields = new List<TextCustomField> { customField }
        };

        // Step 4: Create the envelope definition
        EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
        {
            // Uses the template ID received from example 08
            TemplateId = RequestItemsService.TemplateId,
            Status = "Sent",
            // Add the TemplateRole objects to utilize a pre-defined
            // document and signing/routing order on an envelope.
            // Template role names need to match what is available on
            // the correlated templateID or else an error will occur
            TemplateRoles = new List<TemplateRole> { signer, cc },
            CustomFields = cf
        };

        // Step 5: Call the eSignature REST API
        EnvelopesApi envelopesApi = new EnvelopesApi(config);
        EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);
© www.soinside.com 2019 - 2024. All rights reserved.