FieldDefault Event
The FieldDefault PeopleCode event enables you to programmatically set fields to default values when they are initially displayed. This event is initiated on all page fields as part of many different processes; however, it triggers PeopleCode programs only when the following conditions are all True:
-
The page field is still blank after applying any default value specified in the record field properties.
This is True if there is no default specified, if a null value is specified, or if a 0 is specified for a numeric field.
-
The field has a FieldDefault PeopleCode program.
In practice, FieldDefault PeopleCode normally sets fields by default when new data is being added to the component; that is, in Add mode and when a new row is inserted into a scroll area.
If a field value is changed, whether through PeopleCode or by a user, the IsChanged property for the row is set to True. The exception to this is when a change is done in the FieldDefault or FieldFormula events. If a value is set in FieldDefault or FieldFormula, the row is not marked as changed.
At save time, all newly inserted and changed rows are written to the database. All newly inserted but not changed rows are not written to the database.
You must attach FieldDefault PeopleCode to the field where the default value is being populated.
Note:
An error or warning issued from FieldDefault PeopleCode causes a runtime error.
FieldDefault PeopleCode can be associated with record fields and component record fields.
Related Topics