Runtime Value Calculation is the tool to use when the value a form field/component should be dynamically calculated based on the value of another form field/component.
For example, if you wanted to have:
- A field called "full-name",
- That was dynamically calculated from the user-provided fields of:
- "first-name" and
Whenever the user changed their input for "first-name" or "last-name", the value of "full-name" would be recalculated.
Applies to: Text Field, Text Area Field, Rich Text Editor, Choice Field (Radio Field, Select Field, Checkbox field), Date Field, Time Field, Hidden Field.
Types of Runtime Value Calculation
Returning a Value
The type of value you return needs to match the field type you are applying the Runtime Value Calculation to:
|INTEGER or FLOAT||Number|
The Date must comply with the Date Range Limits (if present) on the date field.
String in 24-hour "HH:MM" format.
The value must comply with the Granularity setting of the field.
For choice fields (radio, select and checkbox), the calculated value MUST be one of the configured choices on the field.
Accessing Other Field Values
There is a special syntax for accessing other field values.
SmartForms can invoke a remote webservice to ask what the value of a field should be. See Using Webservices to Populate Form Data section for more details on how to setup this option.
How To Use Runtime Value Calculation
You assign runtime value calculation in the Runtime Value Calculation Editor in the Visual Designer. See Assigning Input Field Values to learn how to open the Editor.
Triggering Runtime Value Calculation without Depending on Other Fields
Usually, Runtime Value Calculation will only happen when a field depends on another field. However, sometimes you may need the field to be recalculated all of the time. For example, to record what time that particular form page was opened.
The Recalculate on Page Load setting enables you to set up Runtime Value without any dependency on other components. It forces recalculation of the runtime value whenever the page where this component is located gets reloaded, for example when user selects this page or clicks Next or Previous button to arrive on the page.