nareshishere

Need to dynamically edit a document inside a template

0 votes

Hi ,

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

0 votes

Hi 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

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Need to dynamically edit a document inside a template

0 votes

It 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

0 votes

Hi 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

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Need to dynamically edit a document inside a template

0 votes

But the problem is we have to edit a document which we have inside a template while cloning a template


Reply to: Need to dynamically edit a document inside a template

0 votes

What calls after cloning to replace the document with few fields added to the original document


Reply to:

0 votes

Invoke 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

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Need to dynamically edit a document inside a template

0 votes

By any  chance can we  able to change the static content of the document after cloning the template?


Reply to: Need to dynamically edit a document inside a template

0 votes

As 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: Need to dynamically edit a document inside a template

0 votes

But 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:

0 votes

Oh, 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

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off