nehme | Posts: 153

Create a Document Based on a Template

0 votes
Hello, How I can create a document from existing template I have? I have put some text fields like signer first name, last name and country, how I can access these fields and pass them while create a document based on a template? Thanks

Duo_Liang | Posts: 3776

Reply to: Create a Document Based on a Template

0 votes
Hi nehme, With OneSpan Sign, you are able to use following two ways to update all your fields in an approval in one call. If you are using C# SDK, you can use following function:
client.ApprovalService.modifySignature(DocumentPackage sdkPackage, String documentId, Signature signature);
If you are using REST API, you can update your approval like below:
PUT /api/packages/{[packageId}/documents/{documentId}/approvals/{approvalId}
and for the request payload, you can simply use a GET method with same API above to get the response payload, fill in "value" attribute with your values for your fields and use this payload for your request. And BTW, the text fields are editable, which means your signers can change it during signing ceremony. If you want to embed these information directly into the document, you can use a Field Injection feature.

nehme | Posts: 153

Reply to: Create a Document Based on a Template

0 votes
Hello, Thanks for your answer. But I have already template with a document include 2 signature blocks. and added 3 fields like first name, last name and country. How i can fill these fields while creating the document from the the template I already has it? Thanks

Duo_Liang | Posts: 3776

Reply to: Create a Document Based on a Template

0 votes
Hi nehme, I checked with that, OneSpan Sign supports the function that update fields' values in approvals when creating the package. I will take REST way as an example:
POST /api/packages/{templateID}/clone
payload:
{
   "name":"Package created from template through REST API",
   "status":"SENT",
   "roles":[
      {
         "id":"PlaceholderId1",
         "type":"SIGNER",
         "signers":[
            {
               "id":"PlaceholderId1",
               "firstName":"1.firstname",
               "lastName":"1.lastname",
               "email":"[email protected]"
            }
         ],
         "name":"PlaceholderId1"
      }
   ],
   "documents":[
      {
         "id":"document 1 ID",
         "approvals":[
            {
               "id":"15q7lAvEZscW",
               "role":"PlaceholderId1",
               "fields":[
                  {
                     "id":"field 1 id",
                     "value":"new value"
                  },
                  {
                     "id":"field 2 id",
                     "value":"new value"
                  },
                  {
                     "id":"field 3 id",
                     "value":"new value"
                  }
               ]
            }
         ]
      }
   ]
}
In the similar JSON structure, you will be able to update all your text fields in one call. Duo

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