OneSpan Sign How To: Creating Fields

Haris Haidary,

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. It is important to note that only the signer of that signature can assign or change the field's value. Once the signature is signed, the value of the field cannot be changed anymore.

Type of fields

There are two kinds of fields: bound and unbound. A bound field is a field whose value is automatically assigned by OneSpan Sign at the moment of signing (e.g. the date of signing). An unbound field , on the other hand, is a field whose value can be assigned or changed only by the relevant signer before the associated signature is signed. An unbound field can also be set to have a default value.

Bound Fields

The following is a list of available bound fields. During package creation, if these fields have been set and placed on the document by the sender, they will be automatically populated once the signatures are signed by the signer.

  • Signer's name
  • Signer's title
  • Company name
  • Signature date

Unbound Fields

The following is a list of available unbound fields.

  • Check Box
  • Text Box
  • Drop-down list: allows the signer to choose one value from a list
  • Radio button: allows the signer to select one of many options
  • Text area: similar to text box but it provides automatic wrap around. There is a 4000 character limit on text areas
  • Label field: a read only field with a value that will be simply stamped on the PDF
OneSpan Developer Community

OneSpan Developer Community

Join the OneSpan Developer Community! Forums, blogs, documentation, SDK downloads, and more.

Join Today

 

The Code

You can download the complete example code from the Developer Community Code Share: Java SDK, .NET SDK, and REST API.

Java SDK

To add a field on a document using the Java SDK, you will first need to create your Field object using the OneSpan Sign FieldBuilder, as shown below.

Field field = FieldBuilder.label()
        .withId(new FieldId("myLabelField"))
	.withValue("Example label field value")
	.atPosition(100, 200)
	.onPage(0)
	.build();

Once you have built your Field object, you call on OneSpan Sign's ApprovalService to add your field on your document and pass the PackageId, SignatureId, and Field objects along with the document id String as parameters.

String labelFieldId = client.getApprovalService().addField(packageId, "sample-contract", signatureid, field);

 

.NET SDK

To add a field on a document using the .NET SDK, you will first need to create your Field object using the OneSpan Sign FieldBuilder, as shown below.

Field field = FieldBuilder.Label()
	.WithId("myLabelField")
	.WithValue("Example label field value")
	.AtPosition(100, 200)
        .OnPage(0)
	.Build();

Once you have built your Field object, you call on OneSpan Sign's ApprovalService to add your field on your document and pass the PackageId, SignatureId, and Field objects along with the document id String as parameters.

string labelFieldId = client.ApprovalService.AddField(packageId, "sample-contract", signatureid, field);

 

REST API

The sample json below shows you how to edit the "approvals" object in order to add fields on your document with the REST API.

{
  "approvals": [
    {
      "id": "ExampleSignatureId",
      "role": "Signer1",
      "fields": [
        {
          "page": 0,
          "top": 200,
          "subtype": "LABEL",
          "height": 50,
          "left": 100,
          "width": 200,
          "id": "myLabelField",
          "type": "INPUT",
          "value": "Example label field value"
        },
        {
          "page": 0,
          "top": 100,
          "subtype": "FULLNAME",
          "height": 50,
          "left": 100,
          "width": 200,
          "type": "SIGNATURE",
          "name": "ExampleSignatureId"
        }
      ],
      "name": ""
    }
  ],
  "id": "sample-contract",
  "name": "Test Document"
}

Running Your Code

Once you've run your code, if you login to OneSpan Sign and head over to the document view of your package, you can view the added signing date field.

You can follow this guide for a complete tutorial on how add, update, and delete a field using the Java SDK, .NET SDK, and REST API.

If you have questions regarding this blog or anything else concerning integrating OneSpan Sign into your application, visit the developer community forums: https://developer.OneSpan.com. 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