DocuSign: How do I dynamically replace placeholders in our source document? - docusignapi

We are attempting to use the DocuSign API for eSignatures on items such as leases & automatic billing authorizations. What I have are a set of .rtf documents provided to me by our legal team, and there are certain sections that need to be replaced dynamically. I have looked through the DocuSign REST API docs, and I think what we are supposed to be using are text tags. Ware using the PHP SDK. I have not set this document up as a template, as it would be great if we could just use a local file on the filesystem and then have placeholders automatically replaced by values specified in our payload.
What we would like to do is have fields in our documents (such as TenantName and TenantAddress) that we can assign values to, and have DocuSign dynamically replace these placeholders with the values we specify. I have tried doing this using Text Tabs, but the values are not being replaced. Here is a code sample:
$document = new Document([
'document_base64' => $b64fc, // base64_encoded value of file_get_contents('path/to/document.pdf')
'name' => 'Autobill Form',
'file_extension' => 'pdf',
'document_id' => '1',
]);
$tag1 = new Text();
$tag1->setTabLabel('TenantName');
$tag1->setValue('Joe Signer');
$tag1->setLocked(true);
$tag1->setDocumentId('1');
$tag1->setPageNumber('1');
$tag2 = new Text();
$tag2->setTabLabel('TenantAddress');
$tag2->setValue('123 Main St.');
$tag2->setLocked(true);
$tag2->setDocumentId('1');
$tag2->setPageNumber('1');
$tabs = new Tabs();
$tabs->setTextTabs([$tag1, $tag2]);
$document->setTabs($tabs);
// other code to set up recipients, envelopes, and get an embedded signing url
When I view the document, these fields are not replaced, and still have their placeholder values. I don't want to use anchors as I need the placeholder to be removed and replaced by DocuSign. I have also tried setting the text tabs on the Signer object, but that did not work either.
What am I doing wrong? This seems like it would be a fairly common use case for the DocuSign API, but I haven't been able to figure this out.

As Inbar states, the DocuSign eSignature API doesn't allow you to modify the underlying document. You'd need to external tooling to prepare the document prior to passing it into the API Call.
That said, one possible option would be to have blank spaces in your document that align with Text tabs. If you pre-populate those tags and set them to be read-only, the placeholders tags will burn-in during the signing session. Spacing, alignment, and font likely won't be perfect, but with some adjustment you can do okay.

Related

How to remove non-matching DocuSign generic template anchor field from signing document c#?

I am sending the document in an envelope to sign along with the template Id to be applied. In this case, I have defined SignHere tabs for 10 signers using AnchorString. Sometimes the signer's count passed to sign the document would 2 sometime it would be 10.
What I am trying to achieve is, when there is only 1 matching signer then the rest of the AnchorString should be removed from documents, and space for those fields should also be managed accordingly.
Like, In below screen, there is only one signer passed for document as Signer2. So, in this case Signer and Signer3 should be removed.
Is that possible to remove those non-matched AnchorString from document and manage the space accordignly using c# DocuSign SDK?
Do I need to set any Envelope property to handle that case or any other configuration need to be done while sending an Envelope?
DocuSign does not remove information from the documents provided so it can not remove the anchor strings that you didn't use in your document. As a workaround you can create your anchor strings with a white font so it matches the background and it will not be noticeable to the user. This will still leave the empty space in the document, to remove the empty space you will need to provide different documents based on the scenario

where is the docusign api tab label wildcard matching documentation

In the api you can select multiple fields with something like this:
Text text = new Text();
text.setTabLabel("\\*_broker");
This will apply settings to all textfields that have names that end with "_broker".
But i want to select ALL text fields in the entire document and "\\*" does not seem to work.
Can anyone tell me how to select all fields from the API, or even better point me to the documentation for the setTabLabel matching format.
I've look all over and it seems alot of the old documentation links no longer work.
Thanks.
You can assign assign all transformed form fields to the first recipient by making them the default recipient (set defaultRecipient to true).
In order to make all of those form fields Collaborative, I believe you'll need to make extra API calls:
First, create the envelope as a draft (status = created instead of sent).
Then make a call to get the list of all the tabs (EnvelopeRecipients::List with include_tabs=true)
Finally, Use the tabLabels (or IDs) in an Envelopes::Update call to add the "shared": "true" parameter to each of them, and update the status to sent to actually send it.

Assign signer to specific signature form field

I'm evaluating DocuSign esignature API (c# SDK) for an e-signature solution.
Our scenario is easy:
single PDF
multiple signers
each signer has its own signature form field defined in the PDF
Is there a way to map specific signature form field inside PDF to specific signer?
What we already tried:
Anchor text is working but it is cumbersome for our clients to position anchor text, changed its color so it is invisible. Also it is error-prone
TransformPdfFields somewhat working but as I understand it is all or nothing it transforms all form fields and all signature fields are mapped to single signer (am I wrong here?)
Thanks.
With DocuSign, each field (SignHere fields, text input fields, etc) is owned by a specific signer or other recipient type. Fields are called tabs in the API.
At a schematic level, the object hierarchy is:
There are multiple ways to map signHere tabs to different signers and locations in your documents:
Use a template. You or your business person can create a template using the DocuSign web tool. Then your app can use the template id to create and send an envelope.
The different signers are referred to as roles in the template. Eg customer signer 1, internal signer etc. Your app assigns specific names / emails to the roles when it creates the envelope.
Assign the tabs (fields) to signers using the API. The tabs can be positioned using absolute locations or via anchor strings.
Use an HTML document as your source documents. You can specify the tab locations in the HTML. See docs.
Use a PDF Form as your source document. If you name the form's fields consistently then you can use the DocuSign composite templates feature to have the form's fields belong to different recipients/signers. I do not recommend this approach if you have control over the source documents. But if you are give PDF Forms as your source documents, you can make use of them.

DocuSign what are the special fields I can add to Word documents to use via the API

I am testing the Docusign API and I can send a document to sign and get it signed in the position I want using the SignHere data structure and setting the AnchorString.
I want to add a field for the signed date but what is the format and field name required. I can't see anywhere that tells me how to type these into a Word document.
I see you can create templates online using Docusign and put in these fields but I don't see how that will work for us. The document will be dynamically created by our document assembly system and then sent via the Docusign API so I need to build in the fields at that point when I add the signature anchor string.
So what is the Word document special field format and list of Docusign available fields please?
Also it would be good to know how to insert a field to ask the signer to enter some text. Any entry box.
Thanks for any help.
If you're using Salesforce to send out these documents, the DocuSign CLM product supports template codes in Word. See docs.
Otherwise, you can only specify locations of fields (tabs) in the Word doc. This is done via anchor strings also known as auto-place fields. Docs.
Placing the anchor strings in your Word doc is the first step. For the second step, I recommend that you create a DocuSign template by using the DocuSign web tool. Then, when you send the document via the API, you combine it with the template. Or better, you can insert the Word document into the template itself.
The advantage of this technique is that your business users, with the right instructions, can update the template by themselves.
An alternative is for the DocuSign API request to specify the document and the various fields (tabs) that should be included in the document for the signers.
Added
Two other options:
Create your source documents as HTML documents. You can include special tags to indicate different types of DocuSign fields. You can also indicate sections of documents that can be expanded/closed by the signer. HTML field documentation.
This is the best approach, IMHO.
Create your source documents as PDF Forms with form fields. DocuSign can then transform the PDF form fields into DocuSign form fields. There are limitations. Docs.

Docusign API, "Correct Document" or just change fields

Using the Docusign API, I am trying to change the fields that exist on a document. When I first create the document, I am able to change field values using "tabs." I get how to do that.
When I am trying to edit, or in Docusign's terms "correct," a document after it has been sent out, but before being signed, I am having trouble figuring out how to access those fields again to change the values.
I have tried using the API avenue described here ( PUT /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}/fields ), but even after successful calls, the values of the fields aren't changing, and I believe it is because I should be trying to access the tabs, as I did when first changing the tab values as I created the document, instead of targeting the fields, since the two seem to be different. Any thoughts? Thank you in advance for your answers.
To update Tab values you should use the putRecipientTabs api.
Once a signer completes the Signing process, the tab values cannot be updated.
Also not all Tab values can be updated. See this answer for more information.
The putEnvelopeDocumentFields api is for a different purpose. Document fields are different from Tabs. Document fields are an array of name-value custom data strings to be added to a document. Custom document field information is returned in the status, but otherwise is not used by DocuSign.
I figured it out.
The "fields" we are seeing on documents are "tabs," and they are children of the recipients.
The hierarchy goes envelope > recipients > tabs, which tabs we were trying to change. Not envelope > document > fields, which refers to something else--just familiarizing with the language of the api.
Here is a link to the reference for how to change "fields" aka "tabs", and that link includes sample requests.
One thing that helped me target my actual fields, since I kept on getting an error that the field didn't exist for the recipient, is to do a get request of all available tabs and use that response body as the request body for the update call (where we change the field values). Then you know the field information will be accurate, paring the body down to exactly the "fields" aka "tabs" you are interested in targeting.

Resources