Docusign API - Can we create Document Custom field from Rest API - docusignapi

I saw we have API calls to create / list Envelope Custom fields.
https://docs.docusign.com/esign/restapi/Accounts/AccountCustomFields/
Is there a call to create Document Custom field to populate in the Admin section , so that we can use it in any template .
https://admindemo.docusign.com/custom-fields
Admin section screen

I believe the operation you're looking for is Create Custom Tabs, which is defined here in the docs: https://docs.docusign.com/esign/restapi/CustomTabs/CustomTabs/create.
The following request creates a new Document Custom Field called "AccountID" that's a required Text Tab with maximum length of 10.
POST /v2/accounts/{accountId}/tab_definitions
{
"tabLabel": "AccountID",
"maximumLength": "10",
"required": "true",
"type": "Text",
}
After this request is executed, the new field (AccountID) is listed on the Document Custom Fields page within the DocuSign web UI (and is available for use in Templates and Envelopes).

Related

JSON request for envelope with single document, two signers, pre-fill fields

I have an envelope with a single document and two signers saved as a server-side template. The signers execute the agreement in a specific order. The document has a number of pre-fill fields in it.
I am trying to automate sending this agreement out using Integromat. Unfortunately, Integromat's module doesn't allow for pre-fill fields in templates, leaving me to create the API request manually. This is where I get stuck.
The closest I have come is the JSON request below, POSTed to:
…/v2.1/accounts/{accountId}/envelopes, with capitalised values filled in automatically:
{
"templateId": "TEMPLATE_ID",
"templateRoles": [
{
"email": "CLIENT_EMAIL",
"name": "CLIENT_NAME",
"roleName": "Recipient",
"tabs": {
"prefillTabs": {
"textTabs": [{
"tabLabel": "Prefill: Purpose",
"value": "PURPOSE_FIELD_DATA"
}]
}
}
}, {
"email": "STAFF_EMAIL",
"name": "STAFF_NAME",
"roleName": "Company"
}
],
"status": "sent"
}
The response from the API is:
The operation failed with an error. [400] A Required field is
incomplete. TabId: GUI_HERE
What I can't figure out is how to get the pre-fill data submitted since it's not tied to a particular signer. I have scoured the v2.1 API documentation but there is no scenario simple enough for this request.
Apologies if I am missing something obvious here; this is my first rodeo with DocuSign's API.
Do you have any idea what I am doing wrong or, better yet, what the body of the request should be for this (presumably) simple scenario?
Update: For pre-fill tabs, you need to have both the tabId and tabLabel, not enough to just have tabLabel like regular tabs.
My guess is a mismatch of the tabId field for the tabs on your template vs. what's in the API request:
You had this value in your request:
Prefill: Purpose
Does it match how the template was set?
I just tried this with composite templates.
When I added the prefill tabs to a recipient I received the error
Error code: INVALID_TAB_OPERATION.
Message: The Tab specified is not valid for the requested operation.
PrefillTab not allowed for recipient.
which makes sense since prefill tabs are associated with a document, not a recipient.
I tried by adding a document to the composite template, but that didn't work either.
I suggest that you use regular tabs. Mark them locked so they can't be changed. Mark them shared so every signer will see them. Then fill in their values as part of your Envelopes:create call.
Here's a live example of doing this. Note the text2 tab which is locked. (It should have the shared attribute set to true. You can add that from the Tabs/text toolbox on the left.)
Also see this blog post about templates.
Integromat does even without using DocuSign Rest APIs.
You can use Powerforms, it will save your cost for Rest APIs.
I recently did this, but issue is for first recipient, you need to send email manually with powerform link.
Here I dynamically construct PowerForm URL where I pass values to pre populate template fields.
To send email from integromat, you can configure Gmail module or any other email module and create html template where you can append Powerform URL in anchor tag

Filling template textTab, how to wrap text value?

I'm using a template with a bunch of standard text fields defined via the browser UI placing fields on a document background. I've selected the "fixed" option for each of these fields, however the text when programmatically filled in via an api call is not wrapping and instead extending outside the prescribed area. How can i have this programmatic value entry of fields but still have them respect the width of the field?
Have tried setting the "fixed" attribute on the field in the template definition UI.
I won't paste the full json I'm passing as it's huge, but I'm using the same tabLabel/value format from the DocuSign example as seen here:
{
"accountId": "301424",
"emailSubject": "API Example - Populating Data in Templates",
"templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA",
"templateRoles": [{
"email": "john.doe#email.com",
"name": "John Doe",
"roleName": "Customer",
"tabs": {
"textTabs": [{
"tabLabel": "CustomerAddress",
"value": "123 Main St. San Francisco, CA 94105"
},
{
"tabLabel": "CustomerSSN",
"value": "12-345-6789"
}]
}
}],
"status": "sent"
}
Expected result would be a wrapped text in the field, however am actually getting text running into subsequent fields:
What I've defined in the template:
What I'm getting in the output (obviously not ideal):
For text fields (text tabs) if you want multiple lines give the field a larger height to enable two (or more) lines of text. The text should wrap automatically.
The height a line of text takes up depends on the text size for the field, which you can set.
You're setting the initial value via the API--will the signer be able to change it? That's a common use case for setting the initial values--enable the signer to update/correct the data as needed. (And DocuSign will tell your app whether the signer changed the value or not.)
If you're setting the value of the field and the signer can not change the value, then you're using using DocuSign as a custom document (not form) generator. That's fine, many apps do that.
If you run into an issue that DocuSign doesn't support then an alternative is to create the custom document using a different technique.
For example, you could create the document in HTML (programmatically) and DocuSign will convert it to a PDF for signing. Or you can create a customized PDF
document yourself, there are many libraries available.

Adding a Notes using WEB API

I have gone through the WEB Api for leads and not able to find a proper field to update Notes for Leads.
I have used SOAP for creating sales order where NoteText is exposed to update the notes and what is the relevant field in WEB
You need to use the note property.
The value for this property must be specified directly (without nested object with value property).
Below is an example of the body of the PUT request:
{
"LeadID": {
"value": 11973
},
"note": "Some very interesting note\nSome other text from new line."
}

Can templates be used to send same PDF form filled with different data to different recipients

We want to integrate docusign functionality in our product where we allow our product users to map PDF Forms to database fields and populate the PDF form as per the mapping.
We want our users to populate PDF forms with appropriate data as per the configured mapping in our application, before they send the filled PDF form to get it signed from different associated recipients. Original PDF form will be same but its fields will contain different data as per the intended recipient.
We do not want users to repeatedly configure Signing Tabs (Tags) for the same PDF forms again and again.
So we thought trying Templates feature available in docusign. I just want to confirm before implementing Templates feature, whether Template feature will allow me to Send the same PDF form with associated recipeints data filled up from our application and send the filled PDF form to recipients to sign.
As per the documentation it is not clear, whether I can upload the document’s bytes of the document to be signed while using the template feature.
Yes you can definitely populate different values for different recipients when using the same DocuSign template. They would not be very useful if you could not.
This has been answered through other posts, see here for example:
Not able to pass in values to docusign template
You just need to use the tabLabel to identify the tab you want to populate and then use the value field to populate it's value dynamically. For instance, to populate to two text fields (ie data tabs) you would do:
{
"accountId": "221765",
"emailSubject": "DocuSign Templates Webinar - Example 2",
"emailBlurb": "Example #2 - Dynamically Populate Form Fields",
"templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA",
"templateRoles": [
{
"email": "jondow#email.com",
"name": "Jon Dow",
"roleName": "RoleOne",
"tabs": {
"textTabs": [
{
"tabLabel": "ApplicantName",
"value": "John Doe"
},
{
"tabLabel": "ApplicantSSN",
"value": "12-345-6789"
}
]
}
}
],
"status": "sent"
}

Reorganize order of documents in a template using REST APIs

In docusign interface, there is an option to change the order of the documents in a template. Is it possible to re-order the documents in a template using REST APIs?
I have a requirement where end-user should be able to
a) select the templates
b) re-order the documents in selected templates
c) Application should form envelope using selected templates and send it.
Both (a) and (c) features are working fine using REST APIs but when it comes to re-ordering the documents within the template, I am unable to find a solution.
This is the JSON request I am using for composite templates:
{"serverTemplates": [
{
"sequence": "1",
"templateId": "'.$template_id.'"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "'.$emp_rec['email_id'].'",
"name": "'.$emp_rec['name'].'",
"recipientId": "1",
"roleName": "Employee",
"routingOrder": "1"
}
]
}
}
]
}
Let me know if any more information required.
The order of documents appearing in an envelope is based on the order used when creating the envelope. The only exception to this is if building a draft envelope and using the PUT .../envelopes api call to add documents to the draft. This method supports the use of "order". Therefore, if creating an envelope via composite templates, the order of documents in the envelope is based on the order of the composites.
For Composite Template envelope construction, you should think of each composite as a "unit of document contribution". In your snippet of a single composite, the lowest numbered sequence is the server template, so it will contribute the document(s) from the server template. All other referenced templates will be "applied" to that document.
It isn't clear from your question whether you want to add documents from server templates or if you are saying that the particular server template has 2 or more documents in the template. If the latter, I strongly recommend breaking them apart into their own individual templates. This will give you maximum flexibility. Since a multi-document server template can't really be applied to a contributed document, I view them as only useful when creating an envelope from that single template.

Resources