psangha

Conditional logic using text tags?

0 votes

Hi - is it possible to use conditional logic on text tags?

For example, if user selects a checkbox, then we want a text field to be mandatory, otherwise it is optional.


Reply to: Conditional logic using text tags?

0 votes

Hi psangha,

 

Unfortunately, text tags syntax hasn't supported conditional fields, in which case, you'll have to apply a two-step approach:
(1)add documents with text tags to the transaction, where the text tags identify the field ID

(2)invoke an additional API/SDK call and add the condition
See the Java SDK sample code I attached for more details.

 

Duo
 


Attachments

Reply to: Conditional logic using text tags?

0 votes

Hi HanyuChen,

We have out current implementation using the REST API, not the Java SDK. What is the best approach here?

1. Use a REST API version of the Java code you posted (do you have a sample I can look through?)

2. Keep the current REST API implementation, but use the SDK for this specific step (i.e. mixing the implementation approach)

 

Our current implementation receives the document to be signed as a byte array, and uses that to create a package, then submits to OneSpan. If we do approach #1, we'd need to:

  1. Receive as byte array
  2. create package
  3. loop through documents
  4. loop through fields
  5. update required attribute

Is this all possible through the REST API?


Reply to:

0 votes

Hi Julian,

 

Thanks for your post! And the above reply was sent from my testing account.

To answer your questions:

I won't suggest you to mix the usage of SDK and REST API. Sometimes SDK integrators have to introduce RESTful code because SDK doesn't always include all the features, however it's not common the other way.

To fully achieve the goal in REST code, you'd follow below three steps:

(1)Create a transaction with document with text tags uploaded - POST /api/packages. The sample word file I attached above give you an idea how to create the text tags

(2)Because you already identified signature ID, field ID in the text tags, you can directly locate the checkbox without looping through, hence invoke a GET call first:
GET /api/packages/{packageId}/documents/{documentId}/approvals/{approvalId}/fields/{fieldId}
Copy and paste the response JSON, then invoke a PUT call:

PUT /api/packages/{packageId}/documents/{documentId}/approvals/{approvalId}/fields/{fieldId}/conditionalFields

And add a "conditions" node to the payload copied above:
{
  "id": "checkbox1",
  "subtype": "CHECKBOX",
  "width": 20,
  "height": 20,
  "left": 96,
  "top": 352,
  "page": 0,
  "type": "INPUT",
  "name": "checkbox1",

  ......
  "conditions": [
    {
      "condition": "document['ecff7dcbae4943842b8c28603f08d3c40ce0342d34c25776'].field['checkbox1'].value == 'X'",
      "action": "document['ecff7dcbae4943842b8c28603f08d3c40ce0342d34c25776'].field['textfield1'].disabled = false"
    }
  ]
}

(4)send the transaction - PUT /api/packages/{packageId} with payload {"status":"SENT"}

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Conditional logic using text tags?

0 votes

Thank you Duo_Liang; we'll review this approach.

I don't see the word file you mentioned as an attachment, can you re-upload?


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