OneSpan Sign How To: Retrieving Field Values

Haris Haidary, August 17, 2016

For this blog in the OneSpan Sign How To series, I will continue where I left off in the Creating Fields blog. Fields enable the placement of additional data in a document at the time of signing. Fields can be placed anywhere inside a document and each field is linked to a particular signature. For example, you can add a textfield on a document for a signer asking for his or her address. Hence, once a document package has been completed, it may be useful to retrieve the values entered in certain fields (e.g. for reporting purposes). In this blog, I will show you how to retrieve field values with the OneSpan Sign Java SDK, .NET SDK, and REST API.

Create And Send A Package

Let's go over a simple example. The first step is to create and send a package containing fields. If you need a comparison to the basic signature object creation or if this is your first time creating a package with the Web UI, SDKs or REST API, see these Quick Start guides available in the Developer Community. For the purposes of this blog, I will create a package with fields through the Web UI. Login to OneSpan Sign and create a new package (transaction in the new UI). Then, add a few fields in a sample document. Also, make sure to use an email you have access to for the signer so you can fill-out the textfields. Here is what my document in my package looks like so far: 1 Go ahead and send your package and fill-out some sample information in the textfields.

Retrieving Field Values

Java/.NET SDK Retrieving the field values is done with the EslClient object. Namely, you will have to use the getFieldValues() method and pass the PackageId object as parameter. The field values will be returned to you as a list from OneSpan Sign, which you can then subsequently loop through to retrieve the values.

List<FieldSummary> fieldSummaries = eslClient.getFieldValues( packageId );
System.out.println( "SignerId || DocumentId || FieldId: Value\n" );

for ( FieldSummary fieldSummary : fieldSummaries ) {
          System.out.println( fieldSummary.getSignerId() + " || " + fieldSummary.getDocumentId() + " || " + 
	  fieldSummary.getFieldId() + ": " + fieldSummary.getFieldValue() );

A complete description of the code is available in the Developer Community Feature Guides, here. You can also download a working code from the guide. REST API To retrieve the field values, you will need to make a GET request to retrieve your document (e.g. GET{packageId}/documents/{documentId}). Then, you will need to loop through the "approvals" object in order to retrieve the field values.

JObject responseJSON = JObject.Parse(response.Content.ReadAsStringAsync().Result);
var approval = responseJSON["approvals"][1];
var fields = responseJSON.SelectToken("approvals[1].fields");

Debug.WriteLine("SignerId || DocumentId || FieldId: Value\n");

foreach (var field in fields)
      Debug.WriteLine(approval["role"] + " || " + "{documentId}" + " || " + field["id"] + ": " + field["value"]);

A complete description of the code is available in the Developer Community Feature Guides, here. You can also download a working code from the guide.

Running Your Code

Below is a screenshot of my console output. Since I created my package through the Web UI, OneSpan Sign assigned randomly generated ids for each field. However, if you create your package through the SDKs or REST API, you can assign your own ids to these fields. 2 If you have questions regarding this blog or anything else concerning integrating OneSpan Sign into your application, visit the developer community forums: That's it from me. Thank you for reading! If you found this post helpful, please share it on Facebook, Twitter, or LinkedIn.

Haris Haidary Junior Technical Evangelist LinkedIn | Twitter