NexJ Logo

Field controls

A field control is an expression that determines the properties of questions in business process and call script templates. Expressions contain a combination of fields, functions, operators, and types.

You might want a question in a form to display only when a previous question has been answered, or filled out with a default answer when the form first opens. Field controls allow you to create expressions that can dynamically control the properties of questions.

You add a field control to a question by entering an expression in the formula editor of the property that you want to control. When a user runs the business process and fills out the form, the expression is evaluated and can modify the property of the question.

Field control properties

The Field Control tab contains the following subtabs, and each corresponds to a property of the question:

Value
Sets the value of the question's answer. The answer field is disabled after the value is set. The expression must return a value that matches the data type of the question. If the data type does not match, the question will display an error when the form is used.

For example, you can set the Account Opening Date question in your business process to the current date and not allow the user filling in the form to change the date. Enter the following code in the Formula field:

Today()

Initialization
Sets the initial value of the question's answer. The answer can be edited after the initial value is set. The expression must return a value that matches the data type of the question. If the data type does not match, the question displays an error when the form is used.

For example, you can set the Account Opening Date question in your business process to the current date by default, but allow the user filling in the form to change the date. Enter the following code in the Formula field:

Today()

The initialization expression for a question is evaluated when the form loads. If the question is pre-populated with a value from a bound field, the expression overwrites the value in the question. To prevent the initialization expression from overwriting the value for a question populated from a bound field, include a null test expression. An example of a null test expression is:

IfNull(field_to_test, initialization_expression)

The field_to_test parameter is the field that the question is bound to. The IfNull function tests the field to see if it is empty, then runs initialization_expression only if the bound field is empty.

For example, the following expression initializes the value for a question only if the proposedStrategyCurrency field is empty:

IfNull(@attributeExtension.proposedStrategyCurrency, If($CURRENT_PAGE.REGION = "Gibraltar","EUR","GBP"))

In this example, if the REGION field on the same page as the question is equal to Gibraltar, the question's value is set to EUR. Otherwise, the value is set to GBP.

Validation
Controls which answers to the question are accepted and saved. The formula is always an IF statement containing three components separated by commas: an expression to be evaluated, the value TRUE which is returned if the expression is true, and the error message which is returned if the expression is false. The  expression must return a Boolean value. If the expression returns 

TRUE

then the value passes validation and will be saved. Otherwise, the specified error message will be displayed to the user.
For example, you can specify that the answer to the Goes by question must be shorter than 25 characters. If the answer is shorter than 25 characters, the nickname will be saved when the form is saved. If the answer is 25 characters or longer, the nickname will not be saved and the error message "Please specify a nickname shorter than 25 characters" will be displayed to the user. Enter the following code in the Formula field:

If(Len($CURRENT_PAGE.goesBy) < 25, TRUE, "Please
              specify a nickname shorter than 25 characters")

Invisible and disabled fields will not be evaluated since their value cannot be changed.

You can use a field control to add a page to a form when a question meets validation criteria. If the user accesses the page, then changes the original answer, the page remains in the form.

Visibility
Controls whether or not the question and answer are shown. The expression must return a Boolean value. If the expression returns TRUE, the question and answer are displayed in the page. If the expression returns FALSE, the question and answer are not displayed. For example, you can make the Spouse's Name question in your business process visible only if the answer to the Marital Status question is "married" or "common law". If the answer is "divorced" or "single", then the question will not display on the form. Enter the following code in the Formula field:

IsIn($CURRENT_PAGE.marital_status, "Common Law", "Married")

If nothing is entered in the Formula field, the question is visible by default.

Enablement
Controls whether or not the question's answer field is enabled. The expression must return a Boolean value. If the expression returns TRUE, the answer field is enabled. If the expression returns FALSE, the answer field is disabled and cannot be used.

For example, you can make the Spouse's Name question in your business process editable only if the answer to the Marital Status question is "married" or "common law". If the answer is "divorced" or "single", the question will be visible but a user will not be able to fill in an answer. Enter the following code in the Formula field:

IsIn($CURRENT_PAGE.marital_status, "Common Law", "Married")

If nothing is entered in the Formula field, the question is enabled by default.

Filter
Controls which values are displayed in a Drop-down Selection or Radio Button question, if the field control is bound to an enumeration. When you bind a field control to an enumeration, you automatically populate all the possible values of the enumeration as potential answers to the question. Use the Filter subtab if you want to limit or control which values are available as potential answers.

Two variables can be used in the Formula field in this subtab:

  • OPTION_VALUE
    Represents the current option value.
  • OPTION_PARENT_VALUE
    Represents the parent of the current option value.

The OPTION_VALUE and OPTION_PARENT_VALUE variables are case sensitive.

For example, you can limit the countries displayed in the Country field to "Canada", "USA", and "Other". Enter the following code in the Formula field:

IsIn(OPTION_VALUE, "Canada", "USA", "Other")

For example, you can limit the car models displayed in the Car Model field only to models produced by a specific car manufacturer. Enter the following code in the Formula field:

OPTION_PARENT_VALUE = "Mazda"

Required
Controls whether the question is required and must always be answered, or is conditionally required, and must be answered under certain conditions.

The Required subtab will only be visible if Required has been selected in the Add Question or Edit Question dialog.

For example, you can make the Spouse's Name question in your business process conditionally required if the answer to the Marital Status question is "married" or "common law." If the answer is "divorced" or "single", then the question will display on the form but users will not need to fill out the question. Enter the following code in the Formula field:

IsIn($CURRENT_PAGE.marital_status, "Common Law", "Married")

If nothing is entered in the Formula field, the question is required by default.

If