jsondocusignapi

Create DocuSign Envelope with Custom Fields


I am trying to add custom fields at the envelope level via the REST API and cannot get the values to be retained. The custom fields have been defined in the UI and come over in the envelope, but without the value that was assigned. If I add a custom field that was not defined in the UI, then it does not come over at all.

If I add the new custom field in a second call after the envelope is initially created, it will work, but that seems extraneous. What am I doing wrong?

Here is the JSON for creating a new custom field in the envelope:

{
    "emailSubject": "Please Print, Complete and Sign Document",
    "emailBlurb": "Please print and complete documents and sign on paper. ",
    "status": "sent",
    "customFields": {"textCustomFields":[{"name":"MyOwnField","required":"true","show":"true","value":"MyValue"}]},
    "compositeTemplates": [{
        "inlineTemplates": [{
            "sequence": "1",
            "recipients": {
                "signers": [{
                    "requireSignOnPaper": "true",          
                    "name":"Millard Fillmore",
                    "email":"dgilbert@firstallied.com",
                    "recipientId": "1",
                    "routingOrder": "1"
                }]
            }
        }],
        "document":
        {
            "documentId": "1",
            "name": "Corestone Account Application.pdf",
            "transformPdfFields": false
        }
    }]
}

Solution

  • The customFields object needs to be located inside the inlineTemplate object. Try this instead:

    {
        "emailSubject": "Please Print, Complete and Sign Document",
        "emailBlurb": "Please print and complete documents and sign on paper. ",
        "status": "sent",
        "compositeTemplates": [{
            "inlineTemplates": [{
                "sequence": "1",        
                "customFields": {
                    "textCustomFields": [{
                        "name": "MyOwnField",
                        "required": "true",
                        "show": "true",
                        "value": "MyValue"
                    }]
                },
                "recipients": {
                    "signers": [{
                        "requireSignOnPaper": "true",
                        "name": "Millard Fillmore",
                        "email": "dgilbert@firstallied.com",
                        "recipientId": "1",
                        "routingOrder": "1"
                    }]
                }
            }],
            "document": {
                "documentId": "1",
                "name": "Corestone Account Application.pdf",
                "transformPdfFields": false
            }
        }]
    }