Subscribe to AppGini tips and tutorials using your favorite RSS news reader by clicking the link to the right.
Read more AppGini tips and tutorials

Inserting automatic values in fields

AppGini allows you to set one or more fields in a table as read-only so that users can't edit them even if they have edit permissions. This is useful if you want to insert an automatic value into a field, without user intervention.

The automatic value inserted into a read-only field depends on the data type of that field, and on the default value you specify for that field in AppGini. The following screenshot shows the field properties that we'll deal with in this article.

For some data types, MySQL automatically inserts a calculated value to the field if set as read-only in AppGini. For example, for the "Timestamp" data type MySQL inserts the date and time when the record was created. The following table lists the automatic values inserted into fields that were set as read-only in AppGini.

Field data type Default value as set in AppGini Automatic value inserted to the field
Date 1 (or any other non-date value) Date the record was created
Date 2009-2-1 (or any other date in the format yyyy-m-d) 2009-2-1 (or any other date specified)
Time stamp* <None> Date and time the record was created/modified
Any other data type Any arbitrary default value The arbitrary value as is
* Only the first timestamp field in a table behaves as specified above.


New features as of AppGini 4.40

AppGini 4.40 introduced a new feature that allows more advanced control of automatic values. If you click the blue arrow to the right of the Default box, a menu will open to choose one of several possible automatic values, as seen below.

For example, if you want a field in your table to display the username of the user who created the record, you can choose Created by username from the menu. This will insert a special tag into the Default box (see the screenshot below). The generated application will recognize this special tag and replace it with the username when a new record is created.


Please note that for most items of the automatic values drop-down to work correctly, you should set the data type of the field to char or varchar.