DocuSign: how to attach custom properties to an envelope - docusignapi

Hello we are looking to attach an application number to Docusign request (an envelope) with the API.
How can we attach custom properties to an envelope, to pass some reference to a particular transaction, so it is part of the payload sent back in the webhook when signing is complete?.
What we have tried is below:
let recipients = docusign.Recipients.constructFromObject({
signers: [signer1],
carbonCopies: [cc1],
applicationNo: app.id,
})
env.recipients = recipients
env.applicationNo = "someApplicationNumber"
env.status = args.status

From your code example, it looks like you want to attach metadata at the envelope (transaction) level. To do that, use EnvelopeCustomFields
You can create use either strings or enumerated string values.
You can include them in the envelope definition. See here or you can use separate API calls for them
You can have them included in the certificate of completion document if you want.
Example using the Node.js SDK for an EnvelopeCustomField named applicationNo:
let textCustomField1 = docusign.TextCustomField.constructFromObject({
name: "applicationNo",
show: "true", // show the field in the certificate of completion
value: "12345"
});
let textCustomFields1 = [textCustomField1];
let customFields1 = docusign.CustomFields.constructFromObject({
textCustomFields: textCustomFields1
});
...
let envelopeDefinition = docusign.EnvelopeDefinition.constructFromObject({
customFields: customFields1,
documents: documents1,
emailSubject: "Please sign the attached document",
recipients: recipients1,
status: "sent"
});
Same example in JSON:
"envelopeDefinition": {
"emailSubject": "Please sign the attached document",
"status": "sent",
"customFields": {
"textCustomFields": [
{
"name": "applicationNo",
"show": "true",
"value": "12345"
}
]
},
"documents": ....
The certificate of completion.
Notice the applicationNo data

Related

POSTMan sample - creating envelope from a template is not populating the user tags

I created a DocuSign template that contains two roles: Provider and Recipient. I did this via the DocuSign Sandbox UI.
In my template, I have one document, with four tabs on it:
1. ProviderName
2. ProviderAddress1
3. RecipientName
4. RecipientAddress
Should I be using CustomFields vs. Tabs?
What's the API call(s) that I should be making to do the following, given a template with a document in it:
create an envelope for specific users
update the text within the document in the template for the specific users
send it out?
In the POSTMan sample, I tried using this URL, doing a POST:
{{baseUrl}}/envelopes
passing in a templateId, and the following JSON below in the POST body:
JSON:
{
"templateRoles": [{
"email": "{{signer1Email}}",
"name": "The Provider",
"roleName": "Provider",
"tabs": {
"textTabs": [{
"tabLabel": "ProviderName",
"value": "This is the provider!"
},
{
"tabLabel": "ProviderAddress1",
"value": "10 Provider Street, Baltimore, MD 21212"
}]
}
},
{
"email": "{{otherEmail}}",
"name": "Test Recipient",
"roleName": "Recipient",
"tabs": {
"textTabs": [{
"tabLabel": "RecipientName",
"value": "This is the recipient!"
},
{
"tabLabel": "RecipientAddress",
"value": "10 Main Street, Baltimore, MD 21212"
}]
}
}],
"emailSubject": "DocuSign API - Signature Request on Document Call",
"templateId": "<<template ID>>",
"status": "sent"
}
This does return an Envelope Id in the response, and I do receive the email with the DocuSign document to sign.
However, the tabs are NOT populated, they're blank.
Are the roles in the Template empty placeholders? If a name/email is defined on the template, the API call won't populate them as you might expect.
Try to add the documentId and pageNumber properties to your tabs. Also, ensure the label matches what is in the original template.
Lastly, you may need to add recipientId as well to each of the recipients to match what is in the template (this one may not be required since you have the roleName but just in case)

Docusign envelope creation without signer name

Is it possible to create a Docusign envelope without giving a name for the signer?
Here is the sample envelope definition from the REST docs
{
"status":"sent",
"emailSubject":"Example of one recipient, type signer",
"documents":[
{
"documentId":"1",
"name":"contract.pdf",
"documentBase64":"base64 document bytes..."
}
],
"recipients":{
"signers":[
{
"name":"Lisa Simpson",
"email":"lisa#email.com",
"recipientId":"1",
"routingOrder":"1",
"tabs":{
"signHereTabs":[
{
"xPosition":"150",
"yPosition":"200",
"documentId":"1",
"pageNumber":"1"
}]
}
}]
}
}
`
Instead of "Lisa Simpson" I want to have a blank string "" to withhold the persons name. Is this allowed? When I try I get back this error INVALID_USERNAME_FOR_RECIPIENT but am wondering if there is a workaround.
Thanks
No. Signers need to have names defined.
An exception to this is if you are using a 'specify recipients' role prior to the signer. In this case, you can have a blank placeholder signer, but the Specify user will be required to enter both a name and email for the signer.
What is your use case for a signer without a name?

Can you add DocumentFields when using a Template?

Preface: It's my understanding that DocumentFields are metadata on a document that are not specifically tied to a recipient (and will thus not be shown as Form Data and can be retrieved on the document level). If this is incorrect, let me know.
Is there anyway to define DocumentFields when using a template? The templates I am using will only ever contain one document. I'm currently creating the DocuSign requests using a combination of templates and uploaded documents. Here is a piece of code that shows the creation of a request using a template:
var compositeTemplate = new CompositeTemplate()
{
ServerTemplates = new List<ServerTemplate>(),
InlineTemplates = new List<InlineTemplate>()
};
var signer = new Signer()
{
RecipientId = primaryRecipient.ID.ToString(),
Name = "Full Name Here",
RoleName = "Role 1", // Matches role on template
Email = "Fakeemail#fakeemail.com",
};
InlineTemplate inlineTemplate = new InlineTemplate()
{
Sequence = "1",
Recipients = new Recipients()
{
Signers = new List<Signer>(),
CarbonCopies = envelopeCarbonCopies // Set but not included here
}
};
ServerTemplate serverTemplate = new ServerTemplate()
{
Sequence = "1",
TemplateId = documentConfigurations[i].TemplateId
};
compositeTemplate.ServerTemplates.Add(serverTemplate);
inlineTemplate.Recipients.Signers.Add(signer);
compositeTemplate.InlineTemplates.Add(inlineTemplate);
The request works and the template is used. However, ServerTemplate object doesn't allow me to specify DocumentFields, and I can't use the Documents property of the inline template since I'm using a template defined in DocuSign.
If I cannot specify DocumentFields on a template through the API, can you do this using the UI?
If the document field you want to set in the server Template are static, then you can follow below steps to add these static documentfields to Server Template and, when Envelope will be created using this Server Template then it will be available in the Envelope as well.
a. Using DS Web App, download the Server Template, it will download as JSON
b. Open the JSON in the text editor (like Notepad++), and go to
documents node in the JSON, and add documentFields as shown below.
"documents": [{
"documentId": "1",
"uri": "/envelopes/40365a36-ddba-4132-a553-40b4d087935b/documents/1",
"name": "Test.pdf",
"order": "1",
"pages": "1",
"documentBase64": "<PDFBytes>",
"display": "inline",
"includeInDownload": "true",
"signerMustAcknowledge": "no_interaction",
"templateLocked": "false",
"templateRequired": "false",
"documentGroup": "content",
"documentFields": [{
"name": "s_businessDocType",
"value": "TL"
}]
}]
c. Save this JSON and re-upload it on WEBApp, it will generate new templateId.
When you will use this Server Template in the envelope, then envelope will have the documentFields present in the serverTemplate.
UPDATE:
If documentFields are dynamic, then follow below steps:
a. Create Envelope in a draft status.
b. Call below endpoint to add documentFields to the document
POST /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}/fields
c. Once you have added the documentFields then change the envelope status to sent using below endpoint
PUT /v2/accounts/{accountId}/envelopes/{envelopeId}

Embedded Signing - Signing from My App

I'm working on get the signing process on an iFrame to Embedded docusign on my app.
I have trying to work on this based on this tutorials:
Docusign Embedded Signing using template
https://developers.docusign.com/esign-rest-api/guides/features/embedding
Based on what I understood, if you want to embedded you have to create the "create the envelope on the fly". So you don't specify the templateId correct?
So what I don't fully get is, how I get the documentBase64 string value? I have to get it manually? Or docusing api has an endpoint that will return that?
Also I want to know, what happen to the custom fields I added to the template? I can't use them?
Right now this is the json I'm sending:
{{baseUrl}}/envelopes
{
"emailSubject":"This is a custom email subjet, look at the doc.",
"status":"sent",
"templateId":"a0847413-35ac-48ed-9ed6-9b7f96019eda",
"templateRoles":[
{
"email":"mauriciotaranto#email.com",
"name":"Mauricio T",
"clientUserId": "1234",
"roleName":"Test",
"routingOrder":"1",
"tabs": {
"textTabs": [
{
"tabLabel": "Custom",
"value": "This is a custom value"
},
{
"tabLabel": "NewCustom",
"value": "Another custom value added using API"
},
{
"tabLabel": "NewCustom1",
"value": "Last custom value added using API"
}
]
}
}
],
}
And then I go to the recipient view to get the URL:
{{baseUrl}}/envelopes/{{envelopeId}}/views/recipient
{
"returnUrl": "https://www.google.com.uy",
"authenticationMethod": "None",
"email": "mauriciotaranto#email.com",
"userName": "Mauricio T",
"clientUserId": "1234"
}
As far as I understood this way will not allow the user to sing the document.
Need to do it with the document instead.
Can you explain to me how this should work?
Thanks!
UPDATE:
Im manually parsing the bytes of the document to base64. and send this json:
"status":"sent",
"emailSubject":"Envelope with Embedded Signer",
"documents":[
{
"documentId":"1",
"name":"contract.pdf",
"documentBase64":bytes
}
],
"recipients":{
"signers":[
{
"email":"mauriciotaranto#hotmail.com",
"name":"Mauricio T",
"recipientId":"1",
"clientUserId":"1234"
}
]
}
}
I change the headers, add the accept: application/json and content-type: multipart/from-data
And this is the response I get:
{
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
}
You can create envelopes in any way, either by using Templates or by passing base64 of document or both as well using Composite Template. When you send templates, then you already have added signers tabs on the document in the templates so you just need to populate the signer details like name and email in creating an envelope and/or pre-populate the DS Tabs value. But when you send document as base64, then you need to tell DocuSign how to add DS Tabs on the document, either by using
X and Y position of the tabs
AnchorString
PDF Field Transformation
Embedded Signing is a type of signing, to implement that you need to just add clientUserId in the signers details. This can be done in both ways either by using template or by passing document as base64 or both as well using Composite Template. Once you have an embedded signer by adding clientUserId then you need to generate signing URL as explained in your qs, by using Recipient View URL, as soon as URL is generated then you will open this URL in IFrame or on new tab.
In the link which you shared is having very small code snippet and it does not have complete example, check Complete Example, and you will see that they are adding DS Tabs on the document using X/Y position.

Docusign API Invalid email address error with signature from document request with inPersonSigner recipient type

I'm currently testing an API call that will ultimately allow for an agent to provide signature and another party to sign in person. In sending the call via API Explorer I continue to receive the following response:
{
"errorCode": "INVALID_EMAIL_ADDRESS_FOR_RECIPIENT",
"message": "The email address for one of the recipients is not valid."
}
I've read in the REST API guide that this needs to be enabled for my account; it may be that my demo dev account does not have this enabled. I just need to verify whether or not that I'm not omitting any essential parameters in this call. I've tried passing in my email (as the account holder) and still receive this error. Here is my request body JSON:
{
"emailBlurb": "test",
"emailSubject": "test",
"documents": [
{
"name": "ChiropractorPlusApplication.pdf",
"documentId": "1"
}
],
"recipients": {
"inPersonSigners": [
{
"hostName": "Joe Host",
"recipientId": "1",
"name": "Name",
"email": "host#gmail.com",
"signerName": "Insured"
}
]
},
"status": "sent"
}
Thanks!
I believe you have found a bug with the REST API Explorer in that it's missing at least one field for In Person Signers. If you look at the REST API documentation you'll see that there's one more required parameter for In Person Signers, which is the hostEmail
Try adding to your JSON
"hostEmail" : "host's email address",
And I have a feeling that will do the trick. See page 275 of REST API v2 PDF for info on In Person Signers recipient type. It first shows a sample request with all the options then below that it lists the required fields for this recipient type:
http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf

Resources