Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 10:50amHi ,
We are having documents inside a template. In runtime user is choosing what documents needs to be esigned based on that we will clone documents from a template and delete the extra roles and will send for esign.
Now we have a requirement like based on the number of signers document inside a template should have dynamic content added, for example one signer one signing instructions and two signers two signing instructions. How it can be achieved ?
We are using web ui and created a template which consists all documents. In runtime we are cloning the template with user selected documents and sending for esign. We are using Rest api.
Thanks in advance!!!
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 10:59amHi Naresh,
Is this requirement related to your previous post where you mentioned creating multiple copies of a document (signing instructions)? If that's the case, may I know why you want multiple signing instructions, are the contents different?
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 11:05amIt a different requirement from my previous note its like in a same document based on number of signers dynamically content need to be added in a document.
Yes the content are different .
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 11:09amHi Naresh,
It's possible to replace an existing document and still keep the fields and signatures, use this API call:
HTTP Request
POST /api/packages/{packageId}/documents
HTTP Headers
Accept: text/html
Content-Type: multipart/form-data
Authorization: Basic api_key
Request Payload
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc1.pdf"
Content-Type: application/pdf
%PDF-1.5
%ÂμÂμÂμÂμ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
{
"name": "Replaced Document",
"id": "keep_the_document_id_same"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--
Similarly, it’s also possible to replace multiple document, with below request
payload:
Request Payload
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc1.pdf"
Content-Type: application/pdf
%PDF-1.5
%ÂμÂμÂμÂμ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc2.pdf"
Content-Type: application/pdf
%PDF-1.5
%ÂμÂμÂμÂμ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
[
{
"name": "Replaced Document1",
"id": "keep_the_document1_id_same"
},
{
"name": "Replaced Document2",
"id": "keep_the_document2_id_same"
}
]------WebKitFormBoundary1bNO60n7FqP5WO4t--
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 11:14amBut the problem is we have to edit a document which we have inside a template while cloning a template
Reply to: But the problem is we have…
Monday, April 12, 2021 at 11:19amThis is temporary not available, because the clone call only accepts application/json request, and doesn't allow you to replace the document content. You have to invoke additional calls after cloning.
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 11:41amWhat calls after cloning to replace the document with few fields added to the original document
Reply to: What calls after cloning to…
Monday, April 12, 2021 at 11:54amInvoke a GET call first:
GET /api/packages/{package_id}/documents/{document_id}/approvals/{approval_id}
Edit the response and add field nodes to the "fields" array (you can also update the existing field values, instead of adding new fields)
Invoke a POST call with the updated payload, which updates ALL fields under this signature:
POST /api/packages/{package_id}/documents/{document_id}/approvals
(It's a POST call not PATCH, so you need to include all fields, no matter if the field values are updated)
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 01:20pmBy any chance can we able to change the static content of the document after cloning the template?
Reply to: By any chance can we able…
Monday, April 12, 2021 at 01:22pmYes, then you'd follow my first reply above.
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 02:14pmAs per your first reply if we replace the document using the api you have mentioned above , i did not understand how the fields and signatures remains same?
Reply to: As per your first reply if…
Monday, April 12, 2021 at 02:17pmYou can go ahead and have an attempt on your testing account, it's designed in this manner that if you only include the ID and name of the document, other attributes will remain the same.
Duo
Reply to: Need to dynamically edit a document inside a template
Monday, April 12, 2021 at 03:06pmBut i need to add some static content to the document which is inside an template. The above example looks like it will work if we modify an document which was added by externally not through cloning a template?
Do we need to get the document from template and modify static contents and again use the above mentioned api to update the static contents ?
Reply to: But i need to add some…
Monday, April 12, 2021 at 03:18pmOh, thought you already have an external tool to generate dynamic content. If you want to achieve it with help of OneSpan Sign's ability and add static content to the document, try adding Label fields to your template and updating its value via the API I shared with you above.
Not sure if you've turned on New Signer Experience, where the label fields would display the value during the signing. But there's one side effect that label field is only visible to its bonded signer, and other recipients won't be able to see the value until this signer has signed.
Duo