Peoplecode Events Flow



The PeopleCode Editor appears, with the selected PeopleCode program, if any, displayed in the editor. Application Message Event Sets These events are not considered part of the Component Processor flow, so they're documented separately from the majority of PeopleCode events. The following events are associated with messages: OnPublishTransform.

Note. With PeopleTools 8, PeopleCode introduces object classes into its programming model.
  • Identify when PeopleCode events occur in the component processor flow. Write PeopleCode programs and choose the events in which to place them. Manipulate data in the component buffer. Use the PeopleCode development tools to write, edit, and debug PeopleCode programs. Program with object-oriented PeopleCode. Create, use, and extend application.
  • PeopleCode that uses the Grid class to events that occur before the grid is built; the earliest event you can use is the Activate event. The Activate event is not associated with a specific row and record at the point of execution. This means you cannot use functions such as GetRecord, GetRow, and so on, which rely on context, without specifying.

Every PeopleCode program is associated with
Application Designer definition and
Event.
Events are predefined points either in the
Component Processor flow or
Program flow (for application messages.)
As each point is encountered, the event fires on each definition, triggering any PeopleCode program associated with that definition and that event.
Each class of definitions in Application Designer can have an event set—a group of events appropriate to that definition. A definition can have zero or one PeopleCode programs for each event in its event set.
In PeopleTools 7.5, only record fields and menu items had event sets. In PeopleTools 8, several more types of definitions have event sets as well:
Definition Type
Availability
Record field
Prior to PeopleTools 8
Component record field
New in PeopleTools 8
Component record
New in PeopleTools 8
Component
New in PeopleTools 8
Page field
New in PeopleTools 8
ActiveX control
New in PeopleTools 8
Pop-up Menu item
Prior to PeopleTools 8
Message
New in PeopleTools 8
Message Channel
New in PeopleTools 8
Note on Application Engine PeopleCode.
An Application Engine program can have a PeopleCode program as an action. Though the right-hand drop-down menu on the PeopleCode editor window shows the text 'OnExecute,' it really isn't an event.
Note on Component Interface PeopleCode.
A Component Interface can have user-defined methods associated with it. These methods aren't part of any processor flow. They're called as needed by the program executing the Component Interface.
Accessing PeopleCode in Application Designer (Overview)
You can access PeopleCode associated with the various Application Designer definitions in several ways.
With record fields and pop-up menu items, the Project View displays PeopleCode programs within the project hierarchy using a lightning bolt symbol.
The programs are named according to their associated events, such as ItemSelected, RowInit, or SaveEdit, as shown in the following illustration. Double-click a record field or pop-up menu item program in the Project View to launch the PeopleCode Editor and load that program for editing.
You can associate PeopleCode with many other types of definitions, such as
Components
Pages
Component Interfaces
Such PeopleCode programs don't display in the Project View. Instead, right-click the definition's name and select View PeopleCode from the pop-up menu. You can also access them from their associated definitions.
PeopleCode can also be associated with the following:
Component records, that is, with specific records included in components
Component record fields, that is, with specific record fields included in components
ActiveX controls
Since component record fields, component records and ActiveX controls don't appear in the Project View at all, you must access their associated programs through their parent definitions, as described for each definition in this section.
Record Field PeopleCode
A record is a table-level definition, such as an SQL table, a View, or a Derived/Work Record. Record fields are child definitions of records, and Record Field PeopleCode programs are child definitions of record fields. A record field can have zero or one PeopleCode programs for each event in the record field event set.
In addition to accessing programs through the Project View, you can also access them from the record definition, and from any page definition that includes that record.
Accessing Record Field PeopleCode From a Record Definition
Record definition fields that have PeopleCode associated with them appear bold in all record views.
You can access the PeopleCode for a given cell by:
Double-click the cell.
Right-click the cell, and select View PeopleCode from the pop-up menu.
Select View, PeopleCode from the main menu.
The PeopleCode Editor appears. If the field/event combination has an associated program, it displays in the editor.
Accessing Record Field PeopleCode From a Page Definition
Right-click a page control and select View Record PeopleCode from the pop-up menu. The PeopleCode Editor appears, displaying the first event in the event set associated with that control's underlying record field.
Pushbutton controls are a special case. You can associate a PeopleCode program with a pushbutton only if its destination is defined as PeopleCode Command. When the end-user clicks a pushbutton defined like this, the FieldEdit and FieldChange events are triggered, so your PeopleCode must be associated with one of those two events. FieldChange is normally used.
To define a command pushbutton:
In the page definition, double-click the pushbutton to access its properties.
Select PeopleCode Command as the pushbutton Destination.
Select the record and field with which your pushbutton, and PeopleCode, are associated.
It's best to associate the pushbutton with a Derived/Work record field, which separates its PeopleCode from the PeopleCode associated with any of the page's other underlying record fields. You can then store generic PeopleCode with this field so you can reuse it with pushbuttons on other pages.
Click OK to return to the page.
Right-click the pushbutton and select View PeopleCode from the pop-up menu to access the PeopleCode
Editor.
Fields and Record Fields - Distinction
Fields are stand-alone definitions, on the same level as records, whose attributes are shared across all records that use the field.
Record fields are owned by the record definitions that include them.
Note. Fields and record fields are also distinct from component record fields. These are the record fields used in a component, as they appear in the component's structure view. Within that context, they have their own independent event sets and PeopleCode programs. For more information, see Component Record Field PeopleCode.
Properties of a field, such as data type and size, affect all records that include the field; therefore any change to a field property affects all records that include the field.
Properties of a record field, such as PeopleCode programs and key settings, are not shared among records; a change to a record field property affects only the record that owns the record field.
Note. PeopleCode programs are owned by record fields and component record fields, not fields.
The events in the Record Field event set are:
FieldChange Event
FieldDefault Event
FieldEdit Event
FieldFormula Event
RowInit Event
RowSelect Event
RowDelete Event
PrePopup Event
SaveEdit Event
SavePreChange Event
Workflow Event
SavePostChange Event
SearchInit Event
SearchSave Event
Component Record Field PeopleCode
Component record field PeopleCode is different from record field PeopleCode.
Component record field PeopleCode is associated with a record field, but only with respect to a component and one of its events.
Use this type of association to tailor your programs to a particular component. This PeopleCode is only accessible through a component's structure display, not from any record definition.
To access PeopleCode associated with a component record field, open the component's structure view, select a field, right-click the field name, and select View PeopleCode from the pop-up menu. A lightening bolt displays next to the field name if PeopleCode is associated with the field at the component level. If PeopleCode is associated with the field at the record level, a lightening bolt doesn't display.
Component Record Field Event Set
FieldChange Event
FieldDefault Event
FieldEdit Event
PrePopup Event
Component Record PeopleCode
Component record PeopleCode is associated with a record definition, but only with respect to a component and one of its events. Use this type of association to tailor your programs to a particular component. This PeopleCode is directly accessible through a component's structure display, not from the record definition.
To access PeopleCode associated with a component record, open the component's structure view, select a record, right-click the record name, and select View PeopleCode from the pop-up menu.
The following events are associated with component search records:
SearchInit Event
SearchSave Event
The following events are associated with component non-search records:
RowDelete Event
RowInit Event
RowSelect Event
SaveEdit Event
SavePostChange Event
SavePreChange Event
Component PeopleCode
Component PeopleCode is associated with a component definition and an event. To access PeopleCode associated with a component, open its structure view, select the component name, right-click the name, and select View PeopleCode from the pop-up menu.
Component Event Set
PostBuild Event
PreBuild Event
SavePostChange Event
SavePreChange Event
Workflow Event
Page PeopleCode
Page PeopleCode is associated with a page definition.
Currently, pages have only the Activate event.
This event is only valid for pages that are defined as Standard or Secondary. This event is not supported for subpages.
To access PeopleCode associated with a page, right-click on any part of the page's definition, except an ActiveX control, and select View Page PeopleCode from the pop-up menu.
Page Activate Event
The page event set consists of a single event, the Activate event, which fires every time the page is activated.
DiagramPage Field Control PeopleCode
Page Field PeopleCode is associated with page fields. The only control that has PeopleCode associated with it is an ActiveX control.
Note. ActiveX controls are not supported in PeopleSoft Internet Architecture.
To access PeopleCode associated with an ActiveX control, select the ActiveX control in the page definition, right-click it and select View Page PeopleCode from the pop-up menu.
Page Field Event Set
The only control that has PeopleCode associated with it is an ActiveX control.
Every ActiveX control has its own unique event set.
The following events are common to all ActiveX control event sets; only these events are part of the Component Processor flow:
PSControlInit Event
PSLostFocus Event
Menu Item PeopleCode
PeopleTools menus come in two types, pop-up and standard, both of which are stand-alone definitions in the project hierarchy.
Important! For the PeopleSoft Internet Architecture, you can only associate PeopleCode with menu items in a pop-up menu.
Menu item PeopleCode programs are associated with pop-up menu items, which are child definitions of pop-up menus.
To define a PeopleCode pop-up menu item:
In the open pop-up menu definition, double-click the menu item to access its properties. If you're creating a new menu item, double-click the empty rectangle at the bottom of the pop-up menu.
The Menu Item Properties dialog box appears. If this is a new menu item, enter a name and a label for the item.
Select PeopleCode from the Type group.
Click OK to close the Menu Item Properties dialog box.
To access pop-up menu item PeopleCode:
Open the pop-up menu definition.
Access the PeopleCode.
Right-click the menu item. If it's defined as a PeopleCode menu item, View PeopleCode is enabled on the pop-up menu.
Select View PeopleCode.
Menu Item ItemSelected Event
The menu item event set consists of a single event, the ItemSelected Event.
This event fires whenever an user chooses a menu item from a pop-up menu; so naturally this is where you put PeopleCode programs that are executed from menu items.
Application Message PeopleCode
Application messages have the following types of Application Designer definitions with associated PeopleCode:
message
message channel
Accessing Message PeopleCode
In a message definition, you can associate a PeopleCode program with the message itself and with each message subscription included in the definition.
To access PeopleCode associated with a message, open the message definition, right-click anywhere in the Message Structure display, and select View PeopleCode from the pop-up menu.
The PeopleCode Editor appears. If that message definition has associated programs, the first one in the application message event set displays in the editor.
Each message subscription entry in a message definition represents a PeopleCode program. To access that program, open the message definition, select the subscription, right-click the subscription name, and select View PeopleCode from the pop-up menu.
The PeopleCode Editor appears, with the message subscription's associated program displayed in the editor.
Accessing Message Channel PeopleCode
In a message channel definition, PeopleCode is associated with the message channel through its message nodes. To access PeopleCode associated with a message channel, open the Routing Rules view, select a message node, right-click on the node's name, and select one of the following from the pop-up menu:
View OnRoutePublication PeopleCode
View OnRouteSubscription PeopleCode
The PeopleCode Editor appears, with the selected PeopleCode program, if any, displayed in the editor.
Application Message Event Sets
These events are not considered part of the Component Processor flow, so they're documented separately from the majority of PeopleCode events. The following events are associated with messages:
OnPublishTransform Event
OnSubscribeTransform Event
The following event is associated with message subscriptions:
Subscription Event
The following events are associated with message channels:
OnRoutePublication Event
OnRouteSubscription Event
How PeopleCode Programs are Stored and Saved
When you save an Application Designer definition, PeopleTools saves all PeopleCode programs belonging to that definition that have been added or modified.
Component record field PeopleCode and component record PeopleCode belong to the component.
If new PeopleCode programs have been added, PeopleTools creates an association between the owning definition and new rows in the PeopleCode table.
If a PeopleCode program is deleted, the association between the owning definition and the program is also deleted.
Saving PeopleCode programs together with their owning definitions helps to guarantee the integrity of the application.
Note. When you save any Application Designer definition, all PeopleCode programs that you've added or changed since the last save will be checked, formatted, and saved at the same time. If you want to format and check the syntax of a single PeopleCode program, use the Validate Syntax command instead of the Save command.
Automatic Backup of PeopleCode
A PeopleCode program is automatically saved to a file while you're working on it. This checkpoint occurs at the following times:
Every 10 keystrokes.
On a save command, just prior to the save being executed (in case the save doesn't actually execute because the code is invalid).
When another PeopleCode program is selected to be edited (if you have two PeopleCode editor windows open at the same time, and you move from one to the other).
The file is saved to your temp directory (as specified in your environment), in a file with the following name:
PPCMMDDYY_HHMMSS.txt
MMDDYY represents the month, date and year, respectively, of the checkpoint, and
HHMMSS represents the hour, minute and second, respectively.
The top of the checkpoint file contains the following information:
[PeopleCode Checkpoint File]
[RECORD.recordname.FIELD.fieldname.METHOD.eventname]
If your PeopleCode program is saved successfully, any checkpoint files associated with that program are automatically deleted.- Record Field PeopleCode
- Page PeopleCode
- Component PeopleCode
- Component Record PeopleCode
- Component Record Field PeopleCode
Note: Component code fires before component record code, which fires before component record field code.
Component Record and Component Record Field Events

PeopleCode Event Summary
An event is the way that the PeopleSoft Application Designer associates a program with a definition. Each event is a predefined point in the component processor flow, commonly referred to as the program flow. When an event is encountered in the program flow, it fires on a component, which triggers the PeopleCode program associated with it to process. Each definition can be a single definition or it can be one of an event set, a group of PeopleCode events that fire in a program flow. A definition can fall outside of the component processor. External processes include: Application Engine programs, component interfaces, and application packages. There is also the standard sign-on event, which allows for the creation of a session with the PeopleSoft application and resides external to any and all events.
PeopleTools Menus
PeopleSoft has two types of menus: standard menus and pop-up menus. Each type of menu is defined separately as a standalone definition within your project. PeopleCode can be used only on pop-up menus, not in standard menus. There is only one event on a pop-up menu to write PeopleCode in—ItemSelected. This event fires whenever a menu item is selected from a pop-up menu.
Defining PeopleCode Pop-Up Menu Items
  1. Create a pop-up menu.
    a. In the menu definition, double-click an existing pop-up menu.
    b. Double-click the empty rectangle at the bottom of the menu.
  2. Enter a name and a label for the item.
  3. Select PeopleCode from the Type group to enter the PeopleCode.
  4. Click OK to close and then save your project.


  • MessageBox is one of the most powerful debugging tools in your tool chest as a PeopleSoft developer.
  • MessageBox is the preferred method by PeopleSoft. But a WinMessage is a good way to make sure the code you are working on is the code being called.
  • Another really terrific way of debugging is to create a log file and log off anything important. With this method you trap the events in a log, and if something occurs you can trace it back and get a very good idea of what occurred.
  • PeopleCode supports Java objects and PeopleSoft delivers the log4j lib in the PS_HOME/class directory. The following methods can be invoked within the log4j: debug(), info(), warn(), error(), fatal(), and log(). These methods generate log requests during application execution so your code can be riddled with them and they will log off and never disturb your customers.
  • If Logic can be used in PeopleCode to turn logging on and off.

Message Catalog

Message catalogs represent the messages you want to go out to your customers in the production environment. They are the messages that you want displayed when a wrong value is typed or a button is used incorrectly. PeopleSoft delivers thousands of these in its applications and you can create thousands of your own. With PeopleSoft 8.5 the location of the message catalog is stored in a new record named PSMSGCATDEFN. The old record was PS_MESSAGE_CATALOG.
PeopleCode variables (except object variables) are all preceded with “&” and then the data type of the assignment statement.
  • ANY
    This variable is used when the data that is being returned into this type is unknown. The use of the type ANY will allow PeopleTools to determine the best match for the variable. Undeclared local variables by default become ANY variables.
  • BOOLEAN
    This variable is a single bit type that can be TRUE(1) or FALSE(0).
  • DATE
    This variable is a standard date that in PeopleCode is in the format YYYY-MM-DD and in the Oracle database is in the format DD-MM-YYY.
  • DATETIME
    This variable is exactly what it says—the date with the time—and is in the following format: YYYY-MM-DD-HH.MI.SS.SSSSSS.
  • TIME
    This variable is expressed as HHMISS. When you use a function that uses TIME, it returns a numeric value.
  • NUMBER
    A NUMBER variable is a decimal value or integers; it can be any number that has decimal points. NUMBER and STRING are the most used variable types in PeopleCode.
  • FLOAT
    This variable represents a floating decimal point number. The FLOAT variable is a number using a machine floating binary point or double precision. And by default the NUMBER data type in PeopleCode is a floating decimal point representation.
  • INTEGER
    This variable is a whole number with no decimal points.
    Tips on when to use NUMBER, INTEGER, or FLOAT variables:
    Use NUMBER when you are unsure, and it will be the primary default way to declare numbers. Use INTEGER when you are counting items; a good example is when you count rows in a rowset. Use FLOAT only when you are performance tuning and the application is alreadyworking—and you know what the result should be.
  • STRING
    This variable can be a combination of letters, special characters, and numbers. It is
    initialized by enclosing the declared string in quotes. You can use either single or double quotes. When you need to enclose a string within a string, one type of quote is enclosed by another type. The “best practice” is to enclose strings in double quotes and embedded strings in single quotes.
  • OBJECT
    OBJECT variables have their own data types:
    -PeopleCode Data Buffer Access Types Field, Record, Row, and Rowset.
    - PeopleCode Display Data Types AnalyticGrid, Chart, Grid, GridColumn,
    and Page.
    -PeopleCode Internet Script Data Types Cookie, Request, and Response.
    -PeopleCode Miscellaneous Data Types AESection, AnalyticInstance, Array, Crypt, Exception, File, Interlink, BIDocs, JavaObject (can only be declared as type Local), Message, MCFIMInfo, OptEngine, PostReport, ProcessRequest, RowsetCache, SoapDoc, SQL, SyncServer, TransformData (can only be declared as type Local), XmlDoc, and XmlNode (objects can only be declared as type Local).
    -Global ApiObject Data TypeObjects Session, PSMessages collection, PSMessages, all tree classes (trees, tree structures, nodes, levels, and etc.), and query classes.
    -Local ApiObject Data Type Objects Meta SQL, Meta HTML, System
    Variables, and RowSet.

Variable Scopes in PeopleCode
There are three basic variable scopes in PeopleCode: Local, Component, and Global.
There are two types of Local variables: an ordinary Local program variable and a Local function variable. A Local program variable is declared and available during the duration of that program, and a Local function variable is available while the function is called and activated.
  • Global A Global variable is valid during the entire session and can be reset during the session. It is important to understand that its life span is associated with the session and you need to remember to clear and reassign depending on when you plan to use the variable. It is used less often because not that many items need to be valid during the entire session.
  • Component A Component variable is only valid when the object or page that it was created on is valid. This type of variable is used in component interface coding.
  • Local A Local variable is valid during the PeopleCode program or function where the variable was defined. It is the most common variable declaration.

Peoplecode Order Of Execution



Logic Statements
  • If-Then-Else
    One of the most common and easiest to use PeopleCode logic statements is the if-then-else statement. It allows you to control the flow of your program, it allows for branching, and it allows processing dependent upon a set of terms.
  • Evaluate
    Another form of branching in PeopleCode is done using the Evaluate statement. It is used when you have multiple conditions that exist and you need to evaluate each of them.
  • For
    For statements can be very useful tools. They are excellent when you need to execute statements multiple times, and you need to loop or iterate through them.
  • While
    The While statement is another way to loop and allow for repeated statements in PeopleCode. The loop will process until the expression is false. In a lot of aspects the For loop and the While loop are very similar. Any break within a loop returns control to the next highest level, and processing will continue with the next statement after the loop ends. While loops do have a danger of being written as a runaway loop, with For loops you do have more control.
  • XLAT
    An XLAT item returns true in a component interface if the value is being retrieved from an XLAT table.

Peoplecode Events Flowers

Note1: Use /* at the beginning of the comment and */ at the end. This is usually used when a block of code is commented out. REM will remark out a single line of code. Put a ; at the end of the REM statement to terminate and note the end of the comment.
Note2: Use <* at the beginning of the comment and *> at the end. This form of commenting is used to comment within another comment.Peoplecode events flow chart

Peoplecode Events Flow In Add Mode

Note3:

Peoplesoft Peoplecode Events Flow

Do not use /+ +/ syntax to make comments, they will be removed by the system the next time you compile or save your PeopleCode as these are used in comments in application classes.