How to prefill values for radio button while sending documents from template?

BoldSign allows you to prefill values for existing form fields when sending documents from a template. This article provides a guide on how to prefill values for radio button fields.

Templates are pre-designed layouts that streamline the process of creating new documents. By offering a consistent structure and format, they help save time, especially when you frequently send the same contracts for signatures to different recipients. Once a template is configured, sending contracts based on it takes less than a minute. For more information, please refer to the Create Template article.

Once you created a template, you can prefill the values for existing form fields and send 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, read about the Template Properties API.

Once you have the IDs for the radio button group and radio group child elements, you can assign the radio group ID to the existingFormFields ID and assign the value as radio button child label which radio button you want to prefill the value.

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

Code snippet

curl -X 'POST' \ 'https://api.boldsign.com/v1/template/send?templateId=6357f511-xxxx-xxxx-8235-7a43be83cffc' \
     -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@cuberflakes.com",
      "signerType": "Signer",
      "signerRole": "Manager",
      "existingFormFields": [
          {
             "id": "RadioGroup1", 
             "value": "RadioChild2"
           },
           {
             "id": "RadioGroup2",
             "value": "RadioChild1"
           }
        
         ],    

    "locale": "EN"
    }
  ],
    
 }'


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

var existingFormFieldCollections = new List<ExistingFormField>
{
    new ExistingFormField(
        id: "RadioGroup1",
        value: "RadioChild2"
    ),
    new ExistingFormField(
        id: "RadioGroup2",
        value: "RadioChild1"
    ),
};
var templateRole = new Roles(
    roleSignerName:"Richard",
    roleSignerEmailAddress:"richards@cuberflakes.com",
    roleSignerIndex:1,
    existingFormFields:existingFormFieldCollections,
    locale: Locales.EN);

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

var sendForSignFromTemplate = new SendForSignFromTemplate()
{
    TemplateId = "6357f511-xxxx-xxxx-8235-7a43be83cffc",
    Roles = roles,
    
};

var documentCreated =  templateClient.SendUsingTemplate(sendForSignFromTemplate);
Console.WriteLine(documentCreated.DocumentId);

import requests
import json

url = "https://api.boldsign.com/v1/template/send?templateId=6357f511-xxxx-xxxx-8235-7a43be83cffc"

payload = {
    "message": "Kindly review and sign this.",
    "roles": [
        {
            "roleIndex": 1,
            "signerName": "Richard",
            "signerEmail": "richards@cuberflakes.com",
            "existingFormFields": [
                {
                    "id": "RadioGroup1",
                    "value": "RadioChild2"
                },
                {
                    "id": "RadioGroup2",
                    "value": "RadioChild1"
                }
            ]
        }
    ]
}

headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API Key}',
    'Content-Type': 'application/json;odata.metadata=minimal;odata.streaming=true'
}

response = requests.post(url, headers=headers, data=json.dumps(payload))

print(response.text)

const axios = require('axios');

async function GetData(){
try{
 
const response = await axios.post(
    'https://api.boldsign.com/v1/template/send',
    {
        'roles': [
            {
                'roleIndex': 1,
                'signerName': 'Richard',
                'signerEmail': 'richards@cuberflakes.com',
                'existingFormFields': [
                    {
                        'id': "RadioGroup1",
                        'value': "RadioChild2"
                    },
                    {
                        'id': "RadioGroup2",
                        'value': "RadioChild1"
                    }
                ]
                
          },
           
        ],
      
        title: "Simple document",
	    message: "Kindly review and sign this.",
    },
    {

        params: {
            'templateId': '6357f511-xxxx-xxxx-8235-7a43be83cffc',
        },
        headers: {
            'accept': 'application/json',
            'X-API-KEY': '{Your API Key}',
            'Content-Type': 'application/json;odata.metadata=minimal;odata.streaming=true'
        }
    }

);
  console.log(JSON.stringify(response.data));
  return response;
  }
  catch (error) {
    console.error('Error:', error.message);
    throw error; // Propagate the error
  } 
}
  GetData();

In the provided code examples, make sure to replace the templateId with the actual ID of the template you created. Also, update the SignerEmail and SignerName properties with the email and name of the signer you wish to send the document. Once the above code is executed, the radio button form field will be successfully prefilled with the provided values.