Rakesh Prajapati
Rakesh Prajapati

Reputation: 1104

Way to select checkbox Tab in create envelope api and read in formdata api is not consistent

I am working with predefined template. Template has checkboxes to capture user's communication preference with following data labels -

COMMUNICATION_PREF-FAX
COMMUNICATION_PREF-EMAIL
COMMUNICATION_PREF-PHONE

In create envelop API call if I want to select a particular checbox for example EMAIL then I have to pass following in request body POST /envelopes

"checkboxTabs": [
    {
        "tabLabel": "COMMUNICATION_PREF-EMAIL",
        "selected": "true"
    }
]

And after signing is complete when I read form fields using formdata api /envelopes/{{envelopeId}}/form_data I get following

{
    "name": "COMMUNICATION_PREF-EMAIL",
    "value": "X",
    "originalValue": "X"
}

As you can see that checkbox state (checked or unchecked) is represented differently in both case. Value is set selected=true is not consistent with how its read back value = "X" I tried passing value = "X" in create envelope api but it doesn't work.

This inconsistency is problem for the calling application. Should it store checkbox state as true/false or X / empty.

Its not possible to apply translation logic (like treat X as selected) because while reading formdata, field type information (whether it's checkbox or not) is not available.

Any advice is much appreciated.

Upvotes: 0

Views: 102

Answers (1)

Matthew Roknich
Matthew Roknich

Reputation: 908

Instead of form_data try this endpoint and include recipients,tabs as a qp:

GET /accounts/[account_id]/envelopes/[envelope_id]include=recipients,tabs.

The response object will contain exactly what you're looking for. Here is a sample:

{
    "status": "completed",
    ...
    "recipients": {
        "signers": [
            {
                "tabs": {
                    "checkboxTabs": [
                        {
                            "name": "",
                            "tabLabel": "Checkbox 105f25...0b2",
                            "selected": "true",
                            "shared": "false",
                            "requireInitialOnSharedChange": "false",  
                             ...

}

If you are hellbent on using the formData API, keep reading:

That formData API should return field type information within the name property. Basic string manipulation will enable you to discern the type. Here's a sample response object from an envelope I created...

{
    "formData": [...]
    "envelopeId": "7719639c-xxxx-xxxx-xxxx-c847ebebb9c6",
    "status": "completed",
    "sentDateTime": "2020-05-29T00:13:00.0000000Z",
    "recipientFormData": [
        {
            "formData": [
                {
                    "name": "Checkbox 105f257e-xxxx-xxxx-xxxx-03bae25e70b2 | tabGroups: [\"Checkbox Group 9620de9a-xxxx-xxxx-xxxx-dbf6c90e98af\"]",
                    "value": "X"
                },
                ...
            ],
            "recipientId": "85c97d0b-xxxx-xxxx-xxxx-fcc000c6400e",
            "name": "Name",
            "email": "[email protected]",
            "SignedTime": "...",
            "DeliveredTime": "..."
        }
    ]
}

Upvotes: 1

Related Questions