Create DocuSign Envelope with Custom Fields - json

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
}
}]
}

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
}
}]
}

Related

How to get JSON data from attributes that start with # or # in Typescript

I am working with a specific API that returns a JSON that looks like the below sample.
I want to get both values that contain the #text and #attr but I get error messages in typescript when I try to get the values.
try using,
album[0]["#attr"]
album[0]["artist"]["#text"]
Hey for JSON you can use get details by its attribute name in it and it's the same for all-weather it starts with # or # it will be the same.
See below code to get the value of your specified key:
Sample JSON:
{
"weeklyalbumchart": {
"album": [
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"#attr": {
"rank": "1"
},
"playcount": "21"
},
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"#attr": {
"rank": "1"
},
"playcount": "21"
}
]
}
}
Read JSON:
#attr ===> json["weeklyalbumchart"]["album"][0]["#attr"]
#text ===> json["weeklyalbumchart"]["album"][0]["artist"]["#text"]
Hope this will help you to understand it.

Directory users update clearing fields not included in resource

Google's documentation states that Users.update will only update fields included in the userResource object. https://developers.google.com/admin-sdk/directory/v1/reference/users/update
In my script, I am able to submit updates successfully, but when I do, fields not specified are cleared out. Here's an example:
Original user resource:
{
orgUnitPath=/,
...
"organizations": [
{
"name": "John",
"title": "developer",
"primary": true,
"department": "IT",
"location": "CA",
"description": "fulltime_employee",
"domain": "acme.com",
"costCenter": "123456"
}]
}
I want to update just one of the fields, title = 'Sr. Developer'. When I submit the partial userResource with Users.update, the rest of the fields within the array element are cleared even though they were not submitted.
Submitted userResource
{
orgUnitPath=/,
...
"organizations": [
{
"title": "sr. developer"
}]
}
Updated user
{
orgUnitPath=/,
...
"organizations": [
{
"name": "",
"title": "sr. developer",
"primary": true,
"department": "",
"location": "",
"description": "",
"domain": "",
"costCenter": ""
}]
}
Is there a way to correct this, or do I need to load each field within the element and submit them all with only the changed fields updated?

Getting an API generated in-person signing envelope tracked through Salesforce Connect

I'm using the rest API to create an in person signing session from salesforce. My envelope creation json is like this:
{
"documents": [{
"documentBase64": "'+base64EncodedDocToSign+'",
"documentId": "1",
"fileExtension": "pdf",
"name": "contract.pdf"
}
],
"emailSubject": "Please Sign",
"recipients": {
"inPersonSigners": [{
"email": "some#gsome.com",
"name": "Luis",
"hostEmail": "some#gsome.com",
"hostName": "Luis",
"signerEmail": "other#gother.com",
"signerName": "Charles",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "s1",
"anchorXOffset": "0",
"anchorYOffset": "0",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
},
"routingOrder": "1",
"clientUserId": "1000",
"embeddedRecipientStartURL": "SIGN_AT_DOCUSIGN",
}
]
},
"status": "sent"
}
The next step would be for the object to be tracked using Connect. Connect is properly configured for the object and works if I "Sign with Docusign" or use a custom button.
I understand I must change the json to include the DSFSSourceObjectId custom field, with value equal to the Id of the object that is originating the request, but if I try to get a customField in there the json is not properly formatted anymore.
I tried adding the customField like:
...
}
]
},
"customFields": [
{
"Name": "DSFSSourceObjectId",
"Value": "' + objectId + '"
}
],
"status": "sent"
}
Is this viable?
I got this working adding the following to the JSON:
"customFields": {
"textCustomFields": [{
"value": "salesforceId",
"required": "false",
"show": "false",
"name": "DSFSSourceObjectId"
}
]
},

Optional DocuSign editor before sending

I am using the DocuSign API to generate digital agreements. So far all has gone well, but I now have a requirement to optionally have the contract sent to a user for editing within DocuSign before it is sent to the signatories.
My existing API calls are fairly simple, just using a template for the document:
POST https://demo.docusign.net/restapi/v2/accounts/<account_id>/envelopes HTTP/1.1
{
"status": "sent",
"templateId": "<template_id>",
"templateRoles": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1"
},
{
"email": "person2#somewhere.com",
"name": "Person Two",
"roleName": "Signatory2"
}
]
}
I need to have the same template sent to an editing user to adjust the envelope details before delivering to the signatories.
Anybody had any luck with a similar requirement?
Things I have tried:
Adding a compositeTemplates to the above request with an inline template that has an editor. This unfortunately removes all of the fields from the document.
Placing the whole request in compositeTemplates with the template selected as a server template, and the recipients in an inline template. This does not correctly match up the recipient roles to the template roles.
You can use the following composite template to add an Editor in addition to the template roles you have.
{
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "<template_id>"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1",
"recipientId": "1"
},
{
"email": "person2#company.com",
"name": "Person Two",
"roleName": "Signatory2",
"recipientId": "2"
}
],
"editors": [
{
"name": "person three",
"email": "personthree#company.com",
"recipientId": "3",
"routingOrder": "0"
}
]
}
}
]
}
]
}

How to create Signature Request with DocuSign for HTML format?

I have it working for PDF and now want to try an HTML document. I am using the method of POSTing a JSON object containing the document bytes base64 encoded. The only examples I find online are using the multipart/form-data method but I would much prefer to just POST a JSON object w/ the document base64 encoded like I did for PDF. Perhaps I need to encode the HTML differently from how I encoded the PDF?
"errorCode": "ANCHOR_TAG_PROCESSING_FAILURE",
"message": "An Error Occurred during anchor tag processing. Invalid document"
Here's the JSON I am POSTing:
{
"recipients": {
"signers": [
{
"email": "my.email#gmail.com",
"name": "Dummy test",
"recipientId": 1,
"tabs": {
"dateSignedTabs": [{
"anchorString": "signer1date",
"fontSize": "Size12",
"name": "Date Signed",
"recipientId": "1",
"tabLabel": "date_signed"
}],
"fullNameTabs": [{
"anchorString": "signer1name",
"fontSize": "Size12",
"name": "Full Name",
"recipientId": "1",
"tabLabel": "Full Name"
}],
"signHereTabs": [
{
"anchorString": "signer1sig",
"name": "Please sign here",
"optional": "false",
"recipientId": "1",
"scaleValue": 1,
"tabLabel": "signer1sig"
}
]
}
}
]
},
"emailSubject": "Dummy Test Request a signature via email",
"documents": [
{
"documentId": "1",
"name": "index.html",
"documentBase64": "PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZCBsYW5nPSJlbiI+Cjx0aXRsZT5Eb2N1c2lnbiBUZW1wbGF0ZTwvdGl0bGU+CjwvaGVhZD4KPGJvZHk+CgoJPGgxPlRyYWRlIEFzc2lnbm1lbnQgQWdyZWVtZW50PC9oMT4KCTxoNCBpZD0iRGF0ZWRBc09mIj5mZWFmPC9oND4KCTxoNCBpZD0iQmV0d2VlbiI+ZmVhZjwvaDQ+Cgk8aDQgaWQ9ImFuZCI+ZmVhZjwvaDQ+CgkKCTxwPnNpZ25lcjFkYXRlPC9wPgoJPHA+c2lnbmVyMW5hbWU8L3A+CgoKPC9ib2R5Pgo8L2h0bWw+"
}
],
"status": "sent"
}
According to the documentation there is a node for fileExtension, when not default (PDF), I believe this needs to be explicitly set.
https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/