Display Settings PropertiesInitial value

Description

The initial value of the field. The initial value defines the default value for new records.

Discussion

Specify the default value for this field in new records. The default value can be literal value or an expression. Expressions can include functions and reference session and page variables. If the initial value is an expression, it must be preceded with an equal (=) sign. For example:

=a5ws_getCurrentUser()

Initializing to Today's Date/Time

For example, the following will set the default to today's date:

=date()

To set the default to the current time or current datetime, the now() function can be used:

=now()

You can also use session variables as default values. For example:

=session.companyName

You can specify NULL to force the default new value to be blank.

You can use Page Variables (i.e. the variables defined in the URL) by prefixing the variable name with 'PageVariable.' For example:

=PageVariable.lastname

Default Values for Numeric Controls

For numeric fields, numbers must be entered with a period for the decimal separator, regardless of the regional settings on the machine where the server is running.

Videos

To learn more about specifying the Initial value, watch the videos below.

Setting the Default Values In New Records In Grid Part

The Grid allows you to enter new records directly in the Grid part or in the Detail View part. The Grid builder allows you to specify default values for fields in new records. This can be done by either specifying the field's "Initial Value" property, or by specifying code in the "onInitialValueCalculate" event.

In the case where data entry is done in the Grid Part (as opposed to the Detail View), the issue with the "onInitialValueCalculate" event (which is a server-side event) is that it is only called once: when the Grid is initially rendered. So, if you enter a new record and then save that record, the event is not called before the next new record is displayed.

This video shows how you can save the value of a field that was just entered inside the Grid's "stateInfo" object, and then use the "afterRowPopulate" event to retrieve that value and use it as a default in the next new record