Apoorva_M | Posts: 5

Creating a Transaction from a Template

0 votes

Hi,

I've been trying to create a package from a template by referring to this documentation: https://community.onespan.com/documentation/onespan-sign/guides/feature-guides/developer/creating-transaction-template. According to this package creation API would be POST /api/packages/{templateId}/clone instead of the usual API POST /api/packages.

I wanted to check if there's a way to fetch the template and thereby its document contents and using that response to create a package with just the API POST /api/packages?


Approved Answer
Duo_Liang | Posts: 3776

Reply to: Creating a Transaction from a Template

0 votes

Hi Apoorva,

 

If you log onto your sender portal > navigate to the template page > preview the uploaded document, my guess is that after processed by document engine, your signature/field tags have already been replaced by OSS fields. That's why when you later downloaded the PDF, you don't have tags on them.

3-30-1

 

Two solutions to work around this:
#1. Avoid having the tags extracted in the template, like the left side of above screenshot resembles. You can either:

(1 From UI)Recreate a template, don't add any recipients, upload the tagged document (you need to remain no recipients, if you later add signers, the tags will still be replaced)

(2 From REST/SDK code)Or, when recreate the template, manually turn off automatic extraction with this setting:
settings > ceremony > extractTextTags : false

I believe the setting is by default turned on at your account, that's why the tags get auto-extracted.

 

#2. Like I described above, on top of downloading the document content, you'll also merge the document node retrieved from template JSON. In this sense, you are no longer use tags to specify signatures but static position after extraction.

 

Duo

 


Duo_Liang | Posts: 3776

Reply to: Creating a Transaction from a Template

0 votes

Hi Apoorva,

 

Thanks for your post! In a normal flow, you'd use POST /api/packages/{templateId}/clone call if you are creating a package out of a template/existing package.

May I know the reason why you want to use POST /api/packages call instead? If you want to pre-set field values or implement any other specific use case, we can figure out together the best way to achieve the goal.

 

Duo


Apoorva_M | Posts: 5

Reply to: Creating a Transaction from a Template

0 votes

Hi Duo,

I'm already using POST /api/packages api to create package for a different usecase but now I wanted to achieve, fetching document from template and then create a package as it involves less code change from my side.  

 


Duo_Liang | Posts: 3776

Reply to: Creating a Transaction from a Template

0 votes

Thanks for the clarification. I understood that you want to combine two use cases into one, but it could be a little bit tricky for "create package out of template" scenario. Are you planning to #1 grab the template JSON and modify the response, or #2 build package JSON in your local, merged with document JSON & binary retrieved from template?

Either way, you can download the document content:
(1)Invoke a GET call /api/packages/{templateId}

(2)Loop through the "documents" node and get the document ID.

(3)Download the document content with either

GET /api/packages/{templateId}/documents/{documentId}/original

GET /api/packages/{templateId}/documents/{documentId}/pdf

 

Some other concerns are around signer, are you using placeholder signer or actual signer in your template? Because the role ID will also be referenced at "documents" > "approvals" > "role", you may want to make sure your package has the same amount and same role ID signers as the template.

 

Duo

 


Apoorva_M | Posts: 5

Reply to: Creating a Transaction from a Template

0 votes

I'm planning for #2 build package JSON in my local, merged with document JSON & binary retrieved from template. The template has documents with signature tags and when I tried this API  - GET /api/packages/{templateId}/documents/{documentId}/original and saved the response as pdf, the documents don't have signature tags on then. How can I retrieve the document along with signature tags?  


Apoorva_M | Posts: 5

Reply to: Creating a Transaction from a Template

0 votes

Thanks a lot for both the solutions. I was able to get the document content along with the tags. 


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