1

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
        }
    }]
}
Kevin
  • 41,694
  • 12
  • 53
  • 70
David
  • 15
  • 1
  • 3

1 Answers1

4

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
        }
    }]
}
Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • This works as is, but I am using a CompositeTemplateId that is needed and that breaks the process. – David Aug 12 '14 at 21:18
  • This breaks... "compositeTemplates": [{ "compositeTemplateId": "1", "inlineTemplates": [{ "sequence": "1", "customFields": { "textCustomFields": [{ "name": "MyOwnField", "required": "true", "show": "true", "value": "MyValue" }] }, – David Aug 12 '14 at 21:20
  • The response is... { errorCode: "ENVELOPE_IS_INCOMPLETE" message: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line." } - nothing changed except the addition of the one composite template id line. – David Aug 12 '14 at 21:21
  • Are you sure you need to include "compositeTemplateId" in the request? It's an optional element, and I've never had to use it. If you omit "compositeTemplateId" from the API request, you can still affiliate document info by using the "documentId" value (i.e., match the value of documentId in the 'document' object of the compositeTemplate structure with the value of documentId you specify in the document content-disposition header). – Kim Brandl Aug 12 '14 at 21:41
  • I tried that previously and there were issues with it, that is why the attribute was created and we need to use it. Seems strange that adding the composite template id breaks things. We are submitting multiple composite templates to handle multiple documents in both wet sign and esign modes. – David Aug 12 '14 at 22:46
  • I'm fairly confident that the customFields belong inside the inlineTemplate object, as I showed in my answer. The fact that including 'compositeTemplateId' in the request breaks things sounds like a seperate issue/problem altogether. I'd suggest that you post a new question for that issue -- and include in your question the full JSON request (including multi-parts for each document, but you can omit the actual document byte streams). That'll allow me (and others) to repro your issue with compositeTemplateId and potentially suggest a solution. – Kim Brandl Aug 12 '14 at 23:40
  • FYI, I've reproduced the issue that you describe with using "compositeTemplateId", and believe I've found the fix as well. As expected, it's unrelated to use of 'customFields'. If you can mark this answer as accepted (since it solved the 'customFields' issue), and post a new question that briefly describes the error you get when using 'compositeTemplateId', I'll answer that question with a proposed solution. These are definitely two separate issues. – Kim Brandl Aug 13 '14 at 00:13
  • Is there any easy way to determine if the request worked? I don't get an error message, but a call to the get custom field information endpoint returns an empty value for the parameter I'm attempting to populate. – Alex Wood Apr 19 '16 at 01:39