Understanding PeopleCode Program Triggers
PeopleCode can be defined on events associated with a record field, a component, a component record, and many other definitions. During the course of the component processor’s flow of execution, these PeopleCode events (or exit points) are encountered in a specific sequence. When an event is encountered, the component processor runs any PeopleCode for that event on each definition.
The following definitions have events that are part of the component processor flow:
| Items | Event Triggers |
|---|---|
|
Components |
Programs associated with a component definition. |
|
Component records |
Programs associated with a component record. |
|
Component record fields |
Programs associated with a component record field. |
|
Pages |
Programs associated with a page definition. |
|
Record fields |
Programs associated with a specific field of a record definition. |
|
Menu items |
Programs associated with a menu item. |
Suppose a user changes the data in a page field, and then presses Tab to move out of the field. This user action initiates the FieldEdit PeopleCode event. The FieldEdit event affects only the field and row where the change took place.
If you have two FieldEdit PeopleCode programs, one associated with the record field and a second associated with the component record field, both programs execute, but only on the specific field and row of data. The FieldEdit PeopleCode program associated with the record field is executed first, and then the FieldEdit PeopleCode program associated with the component record field is executed.
By contrast, suppose a user has opened a component for updating. As part of building the component, the component processor encounters the RowInit event. This event triggers any RowInit PeopleCode programs on every record field on every row of data in the component. In a scroll area with multiple rows of data, each RowInit PeopleCode program is executed once for each row.
In addition, if you have RowInit PeopleCode associated with both the record field and the component record, both programs are executed on every row of data in the component. The RowInit PeopleCode program associated with the record field is executed first, and then the RowInit PeopleCode program associated with the component record is executed. If you set the value of a field with the record field RowInit PeopleCode, and then reset the field with the component record RowInit PeopleCode, the second value appears to the user.
When you develop with PeopleCode, you must consider when and where your programs are triggered during execution of the component processor flow in addition to what that program executes.
This section discusses how to:
-
Access PeopleCode programs.
-
Understand the execution order of events and PeopleCode.
Related Topics