Docusign : create envelope with recipient custom field

1.5k views Asked by At

I'm trying to create an envelope based on a template and assign a custom field to one of the recipients ("customFields": ["5616999"] , which is the employee ID).

This is my POST REST API: URI : https://demo.docusign.net/restapi/v2/accounts/{accountid}/envelopes

Payload:

 { "status":"sent",
"emailSubject": "Test with template and custom field",
"templateId": "447e6671-74d1-45ce-bf3b-aa7a5c235ea5", "documents": [{ "documentId": "25407849", "name": "testTemplateDoc2.pdf", "documentBase64": " my base64 string of the document"}], 
"templateRoles": [{
        "email": "[email protected]",
        "name": "john doe",
        "recipientId": "10501840",
        "roleName": "RH",
        "routingOrder": "1",
        "emailNotification": {
            "emailBody": "text12808",
            "emailSubject": "Signez ce document [[Collaborateur_UserName]]",
            "supportedLanguage": "fr"
        },
        "recipientSignatureProviders": [{
                "signatureProviderName": "universalsignaturepen_opentrust_hash_tsp",
                "signatureProviderOptions": {
                    "sms": "+33265555555"
                }
            }
        ],
        "tabs": {
            "signHereTabs": [{
                    "anchorString": "/RH1/",
                    "anchorUnits": "pixels",
                    "anchorXOffset": "0",
                    "anchorYOffset": "0",
                    "name": "Please sign here",
                    "optional": "false",
                    "recipientId": "10501840",
                    "scaleValue": 1
                }
            ]
        }
    }, {
        "email": "[email protected]",
        "name": "jane doe",
        "recipientId": "61432066",
        "roleName": "Collaborateur",
        "routingOrder": "2",
        "emailNotification": {
            "emailBody": "text2 2808",
            "emailSubject": "Signez votre document Mr. [[Collaborateur_UserName]]",
            "supportedLanguage": "fr"
        },
        "recipientSignatureProviders": [{
                "signatureProviderName": "universalsignaturepen_opentrust_hash_tsp",
                "signatureProviderOptions": {
                    "oneTimePassword": "1234"
                }
            }
        ],
        "tabs": {
            "signHereTabs": [{
                    "anchorString": "/S1/",
                    "anchorUnits": "pixels",
                    "anchorXOffset": "0",
                    "anchorYOffset": "0",
                    "name": "Please sign here",
                    "optional": "false",
                    "recipientId": "61432066",
                    "scaleValue": 1
                }
            ]
        },
        "customFields": ["5616999"]
    }, {
        "email": "[email protected]",
        "name": "john3 doe3",
        "recipientId": "64377607",
        "roleName": "Directeur",
        "routingOrder": "3",
        "emailNotification": {
            "emailBody": "text3 2808",
            "emailSubject": "consultez le document de Mr. [[Collaborateur_UserName]]",
            "supportedLanguage": "fr"
        },
        "recipientSignatureProviders": [{
                "signatureProviderName": "universalsignaturepen_opentrust_hash_tsp",
                "signatureProviderOptions": {
                    "oneTimePassword": "1234"
                }
            }
        ]
    }
]
}

SO I got a 200 OK and my envelope was created successfully, however the recipient custom field does not appear when I do a simple GET on the envelope. I think it's not taken into account. This is my GET URI

https://demo.docusign.net/restapi/v2/accounts/{accountID}/envelopes/{envelopeid}/recipients?include_extended=true&include_tabs=true

this is the result :

{
    "signers": [
        {
            "tabs": {
                "signHereTabs": [
                    {
                        "stampType": "signature",
                        "name": "Please sign here",
                        "tabLabel": "Sign Here",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "1",
                        "recipientId": "1",
                        "pageNumber": "1",
                        "xPosition": "69",
                        "yPosition": "688",
                        "anchorString": "/RH1/",
                        "anchorXOffset": "0",
                        "anchorYOffset": "0",
                        "anchorUnits": "pixels",
                        "tabId": "a3c9e24a-054c-4e39-bb85-ff602c9afd15"
                    }
                ]
            },
            "signInEachLocation": "false",
            "creationReason": "sender",
            "isBulkRecipient": "false",
            "recipientSignatureProviders": [
                {
                    "signatureProviderName": "universalsignaturepen_opentrust_hash_tsp",
                    "signatureProviderOptions": {
                        "sms": "+330642037079"
                    }
                }
            ],  
            "name": "john doe",
            "email": "[email protected]",
            "recipientId": "1",
            "recipientIdGuid": "77e97f08-552e-4e5b-ab0d-1802d72813cf",
            "requireIdLookup": "false",
            "userId": "0358b4e5-2c64-4d37-a6c2-d9f099ff5071",
            "routingOrder": "1",
            "note": "",
            "roleName": "RH",
            "status": "created",
            "deliveryMethod": "email",
            "templateLocked": "false",
            "templateRequired": "false",
            "emailNotification": {
                "emailSubject": "[BPMED] Signez ce document [[Collaborateur_UserName]]",
                "emailBody": "text12808",
                "supportedLanguage": "fr"
            },
            "totalTabCount": "1"
        },
        {
            "tabs": {
                "signHereTabs": [
                    {
                        "stampType": "signature",
                        "name": "Please sign here",
                        "tabLabel": "Sign Here",
                        "scaleValue": 1,
                        "optional": "false",
                        "documentId": "1",
                        "recipientId": "2",
                        "pageNumber": "1",
                        "xPosition": "69",
                        "yPosition": "264",
                        "anchorString": "/S1/",
                        "anchorXOffset": "0",
                        "anchorYOffset": "0",
                        "anchorUnits": "pixels",
                        "tabId": "5bf64798-f22a-4f08-9bfd-da5745c1c0a0"
                    }
                ]
            },
            "signInEachLocation": "false",
            "creationReason": "sender",
            "isBulkRecipient": "false",
            "recipientSignatureProviders": [
                {
                    "signatureProviderName": "universalsignaturepen_opentrust_hash_tsp",
                    "signatureProviderOptions": {
                        "oneTimePassword": "1234"
                    }
                }
            ],

            "name": "jane doe",
            "email": "[email protected]",
            "recipientId": "2",
            "recipientIdGuid": "c3de6e46-be6a-4ccf-b939-30c0cd251849",
            "requireIdLookup": "false",
            "userId": "e0a726f8-a89d-4b86-99fc-153150cd4892",
            "routingOrder": "2",
            "note": "",
            "roleName": "Collaborateur",
            "status": "created",
            "deliveryMethod": "email",
            "templateLocked": "false",
            "templateRequired": "false",
            "emailNotification": {
                "emailSubject": "[BPMED] Signez votre document Mr. [[Collaborateur_UserName]]",
                "emailBody": "text2 2808",
                "supportedLanguage": "fr"
            },
            "totalTabCount": "2"
        }
    ],
    "agents": [],
    "editors": [],
    "intermediaries": [],
    "carbonCopies": [],
    "certifiedDeliveries": [
        {

            "name": "john3 doe3",
            "email": "[email protected]",
            "recipientId": "3",
            "recipientIdGuid": "b9569f7c-996d-4549-88f6-1e05e9b96ea7",
            "requireIdLookup": "false",
            "userId": "6f0b5463-3baa-4607-bcc9-1958873c12e2",
            "routingOrder": "3",
            "note": "",
            "roleName": "Directeur",
            "status": "created",
            "templateLocked": "false",
            "templateRequired": "false",
            "emailNotification": {
                "emailSubject": " consultez le document de Mr. [[Collaborateur_UserName]]",
                "emailBody": " text3 2808",
                "supportedLanguage": "fr"
            },
            "totalTabCount": "0"
        }
    ],
    "inPersonSigners": [],
    "recipientCount": "3"
}

I've tried creating the envelope in draft mode and then making a PUT request to add the custom field, but it didn't work either...

PS: I've successfully created envelopes with recipient custom fields (not based on a template) and it was ok and the recipient custom field was well integrated in the envelope.

1

There are 1 answers

3
Praveen Reddy On BEST ANSWER

You can use DocuSign compositeTemplates and specify the recipient custom fields. Here is an example. templateRoles does not support specifying recipient custom fields

{
    "emailSubject": "Test with template and custom field",
    "status": "sent",
    "compositeTemplates": [
        {
            "serverTemplates": [
                {
                    "sequence": "1",
                    "templateId": "447e6671-74d1-45ce-bf3b-aa7a5c235ea5"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": "1",
                    "recipients": {
                        "signers": [
                            {
                                "email": "[email protected]",
                                "name": "john doe",
                                "recipientId": "10501840",
                                "roleName": "RH",
                                "routingOrder": "1",
                                "customFields": [ "5616999" ],
                                "tabs": { },
                                "emailNotification": { },
                                "recipientSignatureProviders": { }

                            }
                        ]
                    }
                }
            ],
            "document": {
                "documentId": "25407849",
                "name": "testTemplateDoc2.pdf",
                "fileExtension": "pdf",
                "documentBase64": ""
            }
        }
    ]
}