How to implement the dynamic logic for IBM form design?
Author: Ellen Liu, Dan BJ Liu/China/IBM
This document introduced how to implement a custom validation for IBM Form. Form fields value will modify according to the dynamic logic.
Customer wants to create a custom validation for an example suppose there are two fields customer_type and customer_type_name. Now if we enter customer_type, the customer_type_name field should not be blank.And if customer_type is blank then customer_type_name field should be blank.
For requirement “if we enter customer_type, the customer_type_name field should not be blank.", we used the calculation in required field.
1.Add two fields customer_type and customer_type_name in the form template.
2.Show Properties of customer_type_name
3.Add calculation in required field as picture1-1.
And for requirement "if customer_type is blank then customer_type_name field should be blank"
I use a constraint bind:
Right click on customer_type_name2 field and choose Action Editor and then click custom action. Choose value from the options.
and then create a constraint bind Picture1-2. <xforms:bind constraint="choose(instance('formData')/page1/customer_type2 = '', . = '', true())" nodeset="instance('formData')/page1/customer_type_name2"></xforms:bind>
that says that customer_type_name2 must be empty when customer_type2 is empty. So the form will look like Picture1-3 this if this constraint fails: