Skip to main content

Introduction

Last updated 19/04/2024

Introduction

Five's If fields allow you to add a JavaScript condition. These fields offer a flexible way to define conditional behavior within your application. By utilizing an If (conditional) field, you can specify that a field's behaviour should be determined by the value of one or more conditions.

Field Equations

There are two accepted formats for If based fields, you can use constant values or equations. When using equations Five's internal properties and functions can be used in the If fields.

Constant Values

The following examples for constant values are used in a Show If field, the values are the same for all other If fields.

Constant value of true indicating to show the field. Example,

true

Constant value of false indicating to hide the field. Example,
false

Equations Evaluated in JavaScript Using Five's Properties and Functions

Equations evaluated in JavaScript must start with an equals

=
sign, the result of the
if
statement needs to evaluate to
true
or
false
.

The following are examples of equations and equations using Five's properties that can be used in the If fields.

=(1===1)
since 1 is equal to 1, this returns
true

=(1===2)
since 1 does not equal 2, this returns
false

=(five.field.Field1 === 'show-it')
If the field Field1 has a value of show-it, the field will display. This kind of evaluation is dynamic, and therefore can return
true
or
false
in real time.

Brackets are optional, the above three expressions can also be written as:

=1===1

=1===2

=five.field.Field1 === 'show-it'


The following are examples of equations using Five's functions that can be used in the If fields.

=(five.isCreate())
if the user is creating a new record this will return
true

=(five.isEdit())
if the user is editing the record this will return
true

The following are examples of equations using a combination of Five's properties and functions that can be used in the If fields.

=(five.isCreate() && five.field.Field1 === 'show-it')
if the user is creating a new record and field Field1 displays show-it, this will return
true