Creating a Document Work Flow
  • 11 Oct 2024
  • 6 Minutes to read
  • Dark
    Light
  • PDF

Creating a Document Work Flow

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDKREST APIAPEX SDK

Java SDK

To download the full code sample see our Code Share site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

.withDocument(newDocumentWithName("Second Document")
                        .fromFile("src/main/resources/document.pdf")
                        .atIndex(2)
                        .withSignature(signatureFor("john@email.com")
                                .onPage(0)
                                .atPosition(100, 100)))
.withDocument(newDocumentWithName("First Document")
                        .fromFile("src/main/resources/document.pdf")
                        .atIndex(1)
                        .withSignature(signatureFor("john@email.com")
                                .onPage(0)
                                .atPosition(100, 100)))

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

DocumentPackage postOrderDocumentsPackage = eslClient.getPackage(packageId);
postOrderDocumentsPackage.getDocument("First Document").setIndex(2);
postOrderDocumentsPackage.getDocument("Second Document").setIndex(1);
 
eslClient.getPackageService().orderDocuments(postOrderDocumentsPackage);

This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the Java SDK, see Creating and Sending a Transaction.

Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

.NET SDK

To download the full code sample see our Code Share site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

.WithDocument(DocumentBuilder.NewDocumentNamed("Second Document")
                            .FromFile("src/main/resources/document.pdf")
                            .AtIndex(2)
                            .WithSignature(SignatureBuilder.SignatureFor("john@email.com")
                                    .OnPage(0)
                                    .AtPosition(100, 100)))
.WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
                            .FromFile("src/main/resources/document.pdf")
                            .AtIndex(1)
                            .WithSignature(SignatureBuilder.SignatureFor("john@email.com")
                                    .OnPage(0)
                                    .AtPosition(100, 100)))

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

 DocumentPackage savedPackage = eslClient.GetPackage(packageId);
savedPackage.GetDocument("First Document").Index = 2;
savedPackage.GetDocument("Second Document").Index = 1;
eslClient.PackageService.OrderDocuments(savedPackage);

This example shows you how to edit the document object.

If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see Creating and Sending a Transaction.

Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

REST API

To download the full code sample see our Code Share site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

HTTP Request

POST /api/packages

HTTP Headers

Accept: application/json
Content-Type: multipart/form-data
Authorization: Basic api_key

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj.... 
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
{
  "documents": [
    {
      "id": "doc1",
      "index": 1,
      "name": "First Document"
    },
    {
      "id": "doc2",
      "index": 2,
      "name": "Second Document"
    }
  ],
  "name": "Document work flow",
  "type": "PACKAGE",
  "status": "DRAFT"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--

For a complete description of each field, see the Request Payload section below.

Response Payload

{
    "id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="
}

Next, to update the document work flow, you will need to make a PUT request to:

https://sandbox.esignlive.com/api/packages/{packageId}/documents

With the following JSON payload:

[{
   "id":"doc1",
   "index":2
 },
 {
   "id":"doc2",
   "index":1
 }
}]

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the REST API, see Creating and Sending a Transaction.

Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

Request Payload Table

Property

Type

Editable

Required

Default

Sample Values

status

string

Yes

No

DRAFT

DRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED

type

string

Yes

No

PACKAGE

PACKAGE / TEMPLATE / LAYOUT

name

string

Yes

Yes

n/a

Document Attributes Example

documents

name

string

Yes

No

n/a

sample doc

id

string

Yes

No

n/a

doc1

index

integer

Yes

No

0

0 / 1 / 2 ...

APEX SDK

To download the full code sample see our Code Share site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

	String document1Id = 'document1'; 
        StaticResource sr1 = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
        Map<String,Blob> doc1 = new Map<String,Blob>();
        doc1.put(document1Id, sr1.Body);
         
        ESignLiveAPIObjects.Document document1 = new ESignLiveAPIObjects.Document();
        document1.name = document1Id;
        document1.id = document1Id;
        document1.index = 1;
        sdk.createDocuments(packageId, document1, doc1);
    	
    	
    	String document2Id = 'document2';
    	StaticResource sr2 = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc2' LIMIT 1];
    	Map<String,Blob> doc2 = new Map<String,Blob>();
    	doc2.put(document2Id, sr2.Body);
    	
    	ESignLiveAPIObjects.Document document2 = new ESignLiveAPIObjects.Document();
        document2.name = document2Id;
        document2.id = document2Id;
        document2.index = 2;
        sdk.createDocuments(packageId, document2, doc2);

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

    	//update docuemnt work flow in existing package
    	pkg = sdk.getPackage(packageId);
    	
    	document1 = getDocument(pkg,'document1');
    	document1.index = 2;
    	document2 = getDocument(pkg,'document2');
    	document2.index = 1;
    	
    	updateDocuments(packageId, pkg.documents);	

This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the Apex SDK, see Creating and Sending a Transaction.

Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence