Articles in this section
Category / Section

How to prefill form fields to be visible to both signers when using templates via API?

Published:
13 mins read

By default, form fields assigned to one signer will not be visible to other signers unless the first signer has completed the signing process. However, you can prefill form fields to be visible to all signers, even if the first signer has not completed the signing process, by using label form fields. The label fields are common fields that will be visible to all the signers and cannot be edited by the signers.

Create template

Start by creating a template that includes label form fields. For guidance on creating templates, refer to the Create Template article.

Once the template is created, you can get the template ID of the template. Then you can prefill the values for existing form fields and send a document from the template. To prefill values for existing form fields in a template, you need to use the Properties API to retrieve the form field IDs and assign values to these fields. For more details, refer to the Template Properties API.
Once you have the IDs for the label fields, you can assign the label form field ID to the existingFormFields ID and specify the value you want to prefill for that label form field.

Here is an example demonstrating how to prefill label field values when sending a document from a template:

Code snippet

cURL

curl -X 'POST' \
'https://api.boldsign.com/v1/template/send?templateId=6357f511-xxxx-xxxx-6235-9a43be83cffc' \
-H 'accept: application/json' \
-H 'X-API-KEY: {Your API Key}' \
-H 'Content-Type: application/json;odata.metadata=minimal;odata.streaming=true' \
-d '{
   "title": "Sample document",
   "message": "Kindly review and sign this.",
   "roles": [
      {
         "roleIndex": 1,
         "signerName": "Richard",
         "signerEmail": "richards@cubeflakes.com",
         "signerType": "Signer",
         "signerRole": "Manager",
         "locale": "EN",
   "existingFormFields": [
      {
         "id": "Label1",
         "value": "James R. Carter"
      },
      {
         "id": "Label2",
         "value": "Carter Realty Group"
      },
      {
         "id": "Label3",
         "value": "RE-98765432"
      }
   ]
      },
      {
         "roleIndex": 2,
         "signerName": "Emma",
         "signerEmail": "emma@cubeflakes.com",
         "signerType": "Signer",
         "signerRole": "Director",
         "locale": "EN"
      }
   ],
   "disableEmails": false,
   "disableSMS": false
}'


C#


using BoldSign.Api;
using BoldSign.Model;
var apiClient = new ApiClient("https://api.boldsign.com",
                "Your API Key");
            var templateClient = new TemplateClient(apiClient);

            var existingFormFieldCollectionsSigner1 = new List<ExistingFormField>
            {
                new ExistingFormField(id: "Label1", value: "James R. Carter"),
                new ExistingFormField(id: "Label2", value: "Carter Realty Group"),
                new ExistingFormField(id: "Label3", value: "RE-98765432")
            };

            var templateRoleSigner1 = new Roles(
                roleSignerName: "Richard",
                roleSignerEmailAddress: "richard@cubeflakes.com",
                roleSignerIndex: 1,
                signerType: SignerType.Signer,
                signerRole: "Manager",
                existingFormFields: existingFormFieldCollectionsSigner1,
                locale: Locales.EN
            );

            var templateRoleSigner2 = new Roles(
                roleSignerName: "Emma",
                roleSignerEmailAddress: "emma@cubeflakes.com",
                roleSignerIndex: 2,
                signerType: SignerType.Signer,
                signerRole: "Director",
                locale: Locales.EN
            );

            var roles = new List<Roles> { templateRoleSigner1, templateRoleSigner2 };

            var sendForSignFromTemplate = new SendForSignFromTemplate()
            {
                TemplateId = "6f26bb2b-b9d8-4420-8a94-5d1392106fab",
                Roles = roles
            };

            try
            {
                var documentCreated = templateClient.SendUsingTemplate(sendForSignFromTemplate);
                Console.WriteLine($"Document Created Successfully: {documentCreated.DocumentId}");
            }
            catch (BoldSign.Api.ApiException ex)
            {
                Console.WriteLine($"API Error: {ex.Message}");
                Console.WriteLine($"Response Content: {ex.Message}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unexpected Error: {ex.Message}");
            }
    

Python


import boldsign

configuration = boldsign.Configuration(api_key="Your API Key")

with boldsign.ApiClient(configuration) as api_client:

    template_api = boldsign.TemplateApi(api_client)
    roles = [
        boldsign.Role(
            role_index=1,
            signer_name="Richard",
            signer_email="richard@cubeflakes.com",
            signer_type="Signer",
            signer_role="Manager",
            locale="EN",
            existing_form_fields=[
                boldsign.ExistingFormField(id="Label1", value="James R. Carter"),
                boldsign.ExistingFormField(id="Label2", value="Carter Realty Group"),
                boldsign.ExistingFormField(id="Label3", value="RE-98765432")
            ]
        ),
        boldsign.Role(
            role_index=2,
            signer_name="Emma",
            signer_email="emma@cubeflakes.com",
            signer_type="Signer",
            signer_role="Director",
            locale="EN"
        )
    ]
    send_for_sign_from_template = boldsign.SendForSignFromTemplateForm(
        roles=roles
    )

    response = template_api.send_using_template(
        template_id="7f29bb2b-b9d8-5420-8a94-5d1472106fab",
        send_for_sign_from_template_form=send_for_sign_from_template
    )

    print(response)



Node.js

const axios = require('axios');

async function sendDocumentForSigning() {
    try {
        const response = await axios.post(
            'https://api.boldsign.com/v1/template/send?templateId=6357f511-xxxx-xxxx-8735-9a43be83cffc',
            {
                title: "Simple document",
                message: "Kindly review and sign this.",
                roles: [
                    {
                        roleIndex: 1,
                        signerName: "Richard",
                        signerEmail: "richard@cubeflakes.com",
                        signerType: "Signer",
                        signerRole: "Manager",
                        locale: "EN",
                        existingFormFields: [
                            {
                                id: "Label1",
                                value: "James R. Carter"
                            },
                            {
                                id: "Label2",
                                value: "Carter Realty Group"
                            },
                            {
                                id: "Label3",
                                value: "RE-98765432"
                            }
                        ]
                    },
                    {
                        roleIndex: 2,
                        signerName: "Emma",
                        signerEmail: "emma@cubeflakes.com",
                        signerType: "Signer",
                        signerRole: "Director",
                        locale: "EN"
                    }
                ]
            },
            {
                headers: {
                    'accept': 'application/json',
                    'X-API-KEY': '{Your API Key}', 
                    'Content-Type': 'application/json;odata.metadata=minimal;odata.streaming=true'
                }
            }
        );

        console.log("Response:", JSON.stringify(response.data, null, 2));
        return response.data;
    } catch (error) {
        console.error('Error:', error.response ? error.response.data : error.message);
        throw error;
    }
}

sendDocumentForSigning();

In the above code examples, replace the templateId with the actual ID of the template you created. Also, update the SignerEmail, SignerName , and label field values with the actual details you want to include in the document. Once the above code is executed, the label form field will be successfully prefilled with the specified values and will be visible to all signers.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied