ben.i

Multiple Conditions for a Conditional Field

0 votes

I'm trying to create a package that has a condition where two fields need to be marked as required if one of two (out of five) radio buttons are selected.

I've tried two ways:

FieldConditionBuilder.NewFieldCondition()
                                   .WithId("condition1")
                                   .WithCondition("document['docId'].field['field1'].value != 'X'")
                                   .WithCondition("document['docId'].field['field2'].value != 'X'")
                                   .WithAction("document['docId'].field['field3'].required = true")
                                   .WithAction("document['docId'].field['field4'].required = true")
                                   .Build();

Which doesn't produce the desired behavior; the latter conditions and actions override the later ones.

And this:

FieldConditionBuilder.NewFieldCondition()
    .WithId("condition1")
    .WithCondition("document['docId'].field['field1'].value != 'X';document['docId'].field['field2'].value != 'X'")
    .WithAction("document['docId'].field['field3'].required = true;document['docId'].field['field4'].required = true")
    .Build();

Which fails to build. Is this possible through the SDK?


Reply to: Multiple Conditions for a Conditional Field

0 votes

HI ben.i,

 

Thanks for your post! If you meant:

- the two fields will be required if either radio 1 or 2 are selected

- the two field will be optional if the other 3 radio options are selected

 

Unfortunately this is not doable in OneSpan Sign conditional field. Consider below condition:

IF radio1 is selected, THEN set text field 3 & 4 as required

This expression also implies when it's not selected, for example when you switch from radio 1 to radio 2:

IF radio1 is not selected, THEN set text field 3 & 4 as optional (this is easy to be ignored)

This is conflict with the radio 2's condition that

IF radio2 is selected, THEN set text field 3 & 4 as required

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Multiple Conditions for a Conditional Field

0 votes

Thanks for the quick reply - would the following be possible? Or do we run into the same issue?

IF radio1                                           THEN text1 required, text2 and text3 optional

IF radio2                                           THEN text2 required, text1 and text3 optional

ELSE (i.e. radio3, radio4, or radio5) THEN text3 required, text1 and text2 optional

 

I was thinking for the ELSE I'd be able to check if both radio1 and radio2 are not selected, but I'm unable to figure out how to check for multiple conditions in the SDK


Reply to:

0 votes

Hi ben.i,

 

I think the most straightforward way to test against a logic is through the UI portal (https://sandbox.esignlive.com/a/login). You can send yourself a testing transaction and add the conditions via the designer UI. If the actual behavior passed the testing, you can open a new tab and compose this API Url: https://sandbox.esignlive.com/api/packages/{packageId} to retrieve the package JSON where the conditions will be presented at the "conditions" node.

 

Back to the logic, I'm afraid it's the same issue. Radio1 controls (marks required) text1, radio2 controls text2, these are all good. However the issue is at the text3 which is controlled by multiple options (radio3 & 4 & 5), therefore will conflict each other if one is not selected.

I think the rule here is - one field can control multiple fields, but if different fields control the same field, it's very likely to cause problem.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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