PeopleCode Events – Easy Notes
PeopleCode is event-driven → means code runs when a specific action (event) happens in the
system.
Events can be tied to fields, records, components, or pages.
1. Activate Event
• Triggered: When a page is activated (first displayed or when you switch tabs).
• Usage:
o Enable/disable fields.
o Hide/show scrolls or sections.
o Apply page-level security.
• Example: If a user doesn’t have access, hide a page when it opens.
Note: Can’t use GetRow, GetRecord directly without context because this runs at page level, not
row level.
2. FieldChange Event
• Triggered: When a field’s value changes (by user or PeopleCode).
• Usage:
o Recalculate values.
o Change appearance (enable/disable fields).
• Example: If Salary or Bonus changes → Total Compensation recalculates automatically.
Often paired with RowInit.
3. FieldDefault Event
• Triggered: When a field has no value and needs a default.
• Usage:
o Automatically set default values when adding new rows or records.
• Example: When creating a new employee record, set Country = “IND” by default.
Rows changed only in FieldDefault are not marked as updated.
4. FieldEdit Event
• Triggered: When a field value is entered/changed and user leaves the field.
• Usage:
o Validate single field.
• Example: If Age < 18 → show Error message.
• Difference with SaveEdit:
o FieldEdit → single field.
o SaveEdit → multiple fields together.
5. FieldFormula Event
• Rarely used (bad performance).
• Triggers in many contexts, so avoid for field logic.
• Convention: Used in FUNCLIB_ records to store reusable functions.
6. ItemSelected Event
• Triggered: When a menu item from a popup is selected.
• Usage:
o Run code depending on selected item.
• Example: Right-click on employee → “Send Email” triggers ItemSelected code.
7. PostBuild Event
• Triggered: After all build events finish.
• Usage:
o Hide/unhide pages.
o Set component-level variables.
• Example: After loading a component, hide Payroll tab if not needed.
8. PreBuild Event
• Triggered: Before component build events.
• Usage:
o Validate search page input.
o Hide/unhide pages before they load.
• Example: If invalid DeptID is entered at search, return error before component opens.
9. PrePopup Event
• Triggered: Just before popup menu opens.
• Usage:
o Control which menu items appear.
• Example: Show “Approve” only if status = Pending.
10. RowDelete Event
• Triggered: When a row is deleted.
• Usage:
o Prevent delete or recalc totals.
• Example: If deleting one line item, update Total Amount.
Cannot stop row insert conditionally, but can stop row delete.
11. RowInit Event
• Triggered: First time system encounters a row (during build/insert/select).
• Usage:
o Initialize fields/controls.
• Example: Set PRODUCT = A × B when row loads.
Don’t use Error/Warning here → causes runtime error.
12. RowInsert Event
• Triggered: When user inserts a row.
• Usage:
o Logic specific to row insertion.
• Example: When adding new dependent, auto-set relationship field.
• RowInit always runs after RowInsert, so don’t duplicate code.
13. RowSelect Event
• Triggered: While fetching rows from DB into buffer.
• Usage:
o Filter rows.
o Use DiscardRow or StopFetching.
• Example: Load only ACTIVE employees in buffer.
• Rarely used, better to filter at SQL/view level.
14. SaveEdit Event
• Triggered: When user clicks Save (before DB update).
• Usage:
o Validate data across multiple fields.
• Example: Start Date < End Date.
• Error → block save.
• Warning → user can choose to continue.
15. SavePreChange Event
• Triggered: After SaveEdit, before DB update.
• Usage:
o Last chance to manipulate data.
o Set high-level keys, sequence numbers.
• Example: Auto-generate Transaction ID before insert.
16. SavePostChange Event
• Triggered: After DB update (commit).
• Usage:
o Update external tables.
o Publish messages, Integration Broker.
• Example: After saving new employee, publish message to Payroll system.
Avoid Errors/Warnings here (causes runtime crash).
17. SearchInit Event
• Triggered: Before Search page displays.
• Usage:
o Set default search values.
• Example: Default Employee ID = %EmployeeId (current user).
18. SearchSave Event
• Triggered: After user enters values on search page and clicks Search.
• Usage:
o Validate search keys.
o Ensure minimum search criteria entered.
• Example: Force user to enter at least one search field.
19. Workflow Event
• Triggered: After SavePreChange but before DB update.
• Usage:
o Trigger workflow actions.
• Example: If Expense > 50,000 → send workflow approval to Manager.
Quick Comparison Table
Event When it runs Main Use
Activate When page is displayed Page-level setup
FieldChange When a field changes Recalc / UI changes
FieldDefault When field is blank (new row) Default values
FieldEdit When field exits (single field check) Validation
FieldFormula Rarely used Store functions
ItemSelected Popup menu option selected Context actions
PostBuild After component build Set variables
PreBuild Before component build Validate search input
PrePopup Before popup menu shows Control menu items
RowDelete On row delete Prevent delete / recalc
RowInit When row first loaded Initialize values
RowInsert When row inserted Row-specific logic
RowSelect While fetching data rows Filter rows
SaveEdit On Save (before DB) Multi-field validation
SavePreChange After SaveEdit, before DB Final adjustments
SavePostChange After DB update Publish/notify
SearchInit Before search page shows Default search values
SearchSave After search input, before search exec Validate search input
Workflow After SavePreChange, before DB update Workflow actions