Conditional logic using text tags?
Thursday, July 22, 2021 at 09:07amHi - 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.
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?
Thursday, July 22, 2021 at 06:05pmHi 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
Reply to: Conditional logic using text tags?
Wednesday, July 28, 2021 at 01:35pmHi 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:
Is this all possible through the REST API?
Reply to: Hi HanyuChen, We have out…
Thursday, July 29, 2021 at 08:22amHi 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
Reply to: Conditional logic using text tags?
Thursday, July 29, 2021 at 08:35amThank you Duo_Liang; we'll review this approach.
I don't see the word file you mentioned as an attachment, can you re-upload?
Reply to: Thank you Duo_Liang; we'll…
Thursday, July 29, 2021 at 09:04amHere you go.