You are on page 1of 37

People code

PeopleCode
Introduction
1. About PeopleCode?
PeopleCode is a High-Powered Programming Language Designed for
PeopleSoft.
PeopleCode is an Object-Oriented Language. (From Version 8 onwards)
PeopleCode is a Visual Language similar to Microsoft Access or Visual Basic.
As most of the coding standards are similar to VB, its easier to learn and
work for developers who already know VB.
Program flow and functionality can be controlled by PeopleCode Events.
PeopleCode events fire at particular times, in particular sequences.
Each event is used for a specific purpose. Some perform validation, some
perform calculations, and some set display characteristics.
2. What are the ways we can access PeopleCode Editors?
Project Work Space: Double click on the Lightning Icon.
Open a Record:
PeopleCode display tab of a Record Definition.
Go to Project Work Space, right click on Record, and click on View
PeopleCode.
Open a Page:
Right Click on Page and select View Page PeopleCode or View Record
PeopleCode.
Go to Project Work Space, right click on Page, and click on View PeopleCode.
Open a Component:
Go to Structure Tab, Click on View PeopleCode. (we can view only
Component record PeopleCode)
Go to Project Work Space, right click on Component, and click on View
PeopleCode.
Open Menu / Popup Menu:
Open Menu / Popup Menu; right click on Menu Item, Select View
PeopleCode.
3. In Which Server PeopleCode will be executed?
All the PeopleCode will be executed on the Application Server.
4. Which PeopleTools Table Stores the PeopleCode related information?
PSPCMPROG Stores the information about PeopleCode like on which Record
Field and on which Event PeopleCode exists. And the Code stores in Binary
Format in PROGTXT field.
5. Is PeopleCode Case-Sensitive?
No. PeopleCode is Case-Insensitive. But String Comparisons are Case-
Sensitive.
EX1:
&Name = Srinivas;
WinMessage(&NAME);
&Name is Same as &NAME, So WinMessage displays the name.
EX2:
&Name1 = "Srinivas";
&Name2 = "SRINIVAS";
If &Name1 = &Name2 Then
WinMessage("Name1 and Name2 are Same.");
Else
WinMessage("Name1 and Name2 are not Same.");
End-If;
Output would be Name1 and Name2 are not Same.
6. How the PeopleCode editor validates the Code?
Code will be Formatted and Validated Automatically when you save the
PeopleCode. If there are no syntax errors then code will be saved.
Validate Syntax Option will simply format and validate the Code; it will not
Save the code in the Database.
7. Is it required to have semicolon at the end of Every PeopleCode
statement?
Yes. Otherwise it will throw an error stating that Syntax error: expecting
statement.
8. How to refer fields in PeopleCode programs?
1. Just specify the field name if the field belongs to the same record it
automatically adds the Record name. if the filed is not available in the record
then it throws an error stating that Field is not defined.
2. Specify the RecordName.FieldName if the field belongs to other record.
3. Caret Character (^):
Assume your writing code on NAME Field of ABC Record. Normally we write
the code like ABC.NAME.Value = Srinivas;
Use the ^ shortcut and write the code like
^ = Srinivas;
^ will be replace with Record and field name.
ABC.NAME = Srinivas;
^.Enabled = True; will be replace with
ABC.NAME.Enabled = True;
9. How many ways we can comment the PeopleCode Statements?
1. REM Single line Comment: Semicolon is required at the end of
statement. Otherwise next line will also be treated as Comment. It
comments till the next semicolon found.
2. /* */ Multiple line Comment: Starts with Forward Slash and Asterisk.
Ends with Asterisk and Forward Slash.
3. <* *>: To Comment Group of Multiple Comments. Starts with Less
Than and Asterisk. Ends with Asterisk and Greater Than.
REM WINMESSAGE("STATEMENT1");
REM WINMESSAGE("STATEMENT2");

WINMESSAGE("STATEMENT3");
WINMESSAGE("STATEMENT4");
<*
/*
WINMESSAGE("STATEMENT5");
WINMESSAGE("STATEMENT6");
*/
/*
WINMESSAGE("STATEMENT7");
WINMESSAGE("STATEMENT8");
*/
WINMESSAGE("STATEMENT9");
WINMESSAGE("STATEMENT10");
*>
WINMESSAGE("STATEMENT11");
WINMESSAGE("STATEMENT12");
10. What is the Use of Find In Option?
Useful to find a Specific String in the entire Database or in a specific Project.
After the Search completed, a text file is created and placed in the Results
Window under the Find In tab.
Click on any result will bring up the PeopleCode Program or SQL statements.
11. What are the Processing Modes available in PeopleSoft?
Interactive & Deferred Modes and Allow Expert Entry
1. Deferred Mode:
Normally called as Standard Mode which is Default Mode.
It defers all the server trips till there is an action by the user
which requires the trip to the server.
2. Interactive Mode:
For every user action there will be a trip to the Application Server.
When the user tabs out of a field that has a field level People Code, there
will be a trip to the Application Server.
Performance wise, use the deferred mode as it reduces the server trips.
We can set these options in Component Level, Page Level and Page Field
Level.
If Interactive is set in Component Level then entire component will
be Interactive.
If Deferred is set in Component level, it checks forInteractive in Page and
Page Field Levels, if Page is set to Interactive entire Page will
be Interactive though component is set to Deferred.
3. Allow Expert Entry:
We can set this option in Component Properties and Users Profile.
If this check box is selected, an Expert Entry check box appears on the
bottom of the Page at runtime.
If the user selects this check box, the transaction runs in deferred mode,
regardless of the setting on the Component, Page, or Field Property
.
12. A Page is having a Push Button and page is in Deferred Mode.
When you click on the Push Button will FieldEdit and FieldChange get
fired or will it wait until you click on Save?
Deferred Mode will not be applicable for Push Buttons and Hyperlinks.
Though page is in Deferred mode, when you click on Push Button, FieldEdit
and FieldChange events will execute.
13. A page is having 2 fields and its in deferred mode, and 2 fields
are having FieldEdit PeopleCode. When you change a value of first
field and Save the page, will FieldEdit PeopleCode of 2 Fields
executes?
No, Only first field FieldEdit PeopleCode fires.
When the next transmission to the server occurs, PeopleTools determines
which fields have changed since the last transmission, and executes the
code accordingly.
14. A Component is having 3 pages and its in deferred mode. When
you switch between the pages, will Page Activate code fires?

15. A page is having a Scroll and it is in deferred Mode. When you try
to Add or Delete a row, will RowInsert and RowDelete code fires?

16. Where can we set the Processing Modes Options?


Component Level: Component Properties, Internet tab.
Page Level: Go to Page Properties, Use tab.
Page File Level: Go to Page Field Properties, Use Tab.
Scroll Area: Go to Scroll Area Properties, Use Tab.

Advantages of PeopleCode
17. What are the Advantages of PeopleCode?
1. Validates the User Inputs.
2. To show Error and Warning Messages.
3. Performs Calculations.
4. Performs Data manipulation.
5. Provides the Security.
6. To set the Default Values.
7. To update Database/Buffer.
8. To Schedule the processes like SQR/AE.
9. To View / Add / Delete Files.
10. To Manage Portal Navigations.
11. To Manage Workflow.
12. To integrate 3rd party Applications.
13. To create applications that run on mobile devices, such as PDAs or
Laptops.

List of Events
18. What are the Record Field Level Events?
Record Field Level Events

Field Level Row Level Save Level Search Level


Events Events Events Events

FieldChange RowSelect SaveEdit SearchInit


FieldDefault RowInit SavePreChange SearchSave
FieldEdit RowInsert Workflow
FieldFormula RowDelete SavePostChange
PrePopUp
19. What are the Component Level Events?
Component Level Events
Component
Component Level Component Record
Record Level
Events Field Level Events
Events
1. PreBuild 1. SearchInit 1. FieldChange
2. PostBuild 2. SearchSave 2. FieldDefault
3. SavePreChange 3. RowSelect 3. FieldEdit
4. Workflow 4. RowInit 4. PrePopUp
5. SavePostChange 5. RowInsert
6. RowDelete
7. SaveEdit
8.SavePreChange
9.SavePostChange

20. What is the Page level Event?


21. What is the Menu level Event?
22. What is the Event available in Application Engine?
23. What is the Event available in Component Interface?
Page Application
Menu Component Interface
Event Engine
Activate ItemSelected OnExecute Methods

24. What are the Message Events?


Message Events
1. OnPublishTransform
2. OnSubscribeTransform
3. OnRouteSend
4. OnRouteReceive
5. OnRequest
25. What are the Component Buffer Events?
RowSelect, PreBuild, RowInit, and PostBuild.

Execution Order of Events


26. Execution order of Events in Add/Search Mode?
Search Mode Add Mode Save
1. SearchInit 1. SearchInit 1. SaveEdit
2. SearchSave 2. SavePreChange
3. RowSelect 3. Workflow
4. PreBuild 2. PreBuild 4. SavePostChange
3.FieldDefault
5. FieldFormula 4. FieldFormula
6. RowInit 5. RowInit
7. PostBuild 6. PostBuild
8. Activate 7. Activate

27. What is the difference between Add Mode and Search Mode?
In Search Mode you can access the existing Component Data where as in
Add mode you can add new row of data to the component.
28. Will SearchInit fires in Add Mode?
Yes, before displaying the Search Page SearchInit code will be get fired then
we can choose either the Search Mode or Add Mode.
29. Will FieldDefault fires in Search Mode?
No, Default Values will be assigned only in Add Mode.
30. Will RowSelect fires in Add Mode?
No RowSelect event fires only when we go with Search Mode.

SearchInit
When is it fired?
SearchInit Event fires just before the Search/Add dialog box displays.
What is the Use?
To assign the default values to Search Keys and Alternate Search Keys.
What are the Restrictions?
SearchInit is valid only for Search Keys and Alternate Search Keys.
If there is any code exists in SearchInit Event for Non Search Keys, it will
not throw an error and as well it will not execute.
SearchInit Event can be accessed from Record Level Field and Component
Record Level Field.
Component Interface will not execute SearchInit PeopleCode.
Dont use functions like DoModal, DoModalComponent, Transfer, and
TransferPage in SearchInit Event.
Examples?
Assume a Component is having Salary details which can be accessed based
on the Search value - UserID.
If there is no validations set, all the Users can see all the Users Salary
details.
This can be restricted by assigning default UserID at SearchInit level. So
that the User who logged into the application can see his/her Salary Details
only
SALARY_DTLS.USERID.Value = %UserId;
SALARY_DTLS.USERID.Enabled = False;
Assume there are no Salary details for XYZ User. If XYZ login
to the application, XYZ cant able to see his details as well as others details
and cant even change the Search value as UserID field got disabled.

Assume Salary Details are there for the User ABC. If ABC login to the same
Page, ABC can see the Salary details of his own. ABC cant even change the
search value and see the others details.
SearchSave
When is it fired?
SearchSave Event fires when user clicks the Search Button.
What is the Use?
Useful to force the User to enter the values into Search Dialog Box.
Useful to restrict the user to access the data unless knowing the Search
values.

Useful to validate the Search values. If the entered value is incorrect then
display the Error or Warning Message and send back the user to the Search
Page.
What are the Restrictions?
SearchSave is also valid only for Search Keys and Alternate Search Keys.
If there is any code exists in SearchSave Event for Non Search Keys, it will
not throw an error and also it will not execute.
SearchSave Event can be accessed from Record Level and Component
Record Level.
Component Interface will not execute SearchSave PeopleCode.
Examples?
Write the below code in SearchSave event of USERID field.
If None(SALARY_DTLS.USERID.Value) Then
Error (MsgGetText(30000, 1, "UserID should not be Blank."));
Else
If SALARY_DTLS.USERID.Value <> %UserId Then
Error (MsgGetText(30000, 2, "Enter the Correct UserID."));
End-If;
End-If;
Assume ABC User login to the Application.
When Search button clicked without entering any value to the UserID field.
It will throw an Error Message.
When Search button clicked without entering the valid UserID, it will throw
an Error Message.

We can also validate using this code too.


If Not RecordChanged(SALARY_DTLS.USERID) Then
Error MsgGet(1000, 168, "At least one key field must be entered.")
End-If;
RowSelect
When is it fired?
RowSelect event fires at the beginning of the Component Build Process in
any of the Update action modes (Update, Update/Display All, Correction).
It also fires after a Scroll Select or related function is executed.
What is the Use?
Useful to filter the data.
We can access the rows of a record that is currently being processed.
Once the data been retrieved from Database Server, RowSelect event
decides whether to copy into Component Buffer or Discard the Row or Stop
Fetching other Rows.
What are the Restrictions?
Component Interface will not execute RowSelect PeopleCode.
Examples?
Assume ABC employee is having 3 rows.

If there is no code exists at RowSelect Event then all the 3 rows will be
fetched into Component Buffer from the Database.
Use DiscardRow() Function to Skip the current row and continue the
processing with next rows. Current Row will be discarded and will not be
available in the Component Buffer.
Write the Below Code in RowSelect
If Year(SALARY_DTLS.PAY_END_DT.Value) = 2001 Then
DiscardRow();
End-If;
Out of 3 Rows, 2001 row will be discarded and remaining 2 rows will be
available in Component Buffer.
StopFetching() Function will Accepts the Current Row and stop reading the
next rows.
Write the Below Code in RowSelect
If Year(SALARY_DTLS.PAY_END_DT.Value) = 2001 Then
StopFetching();
End-If;
2000 and 2001 rows will be fetched into Component Buffer. And then stops
the processing. So 2002 will not be available in Component Buffer.

Use DiscardRow() and StopFetching() Functions in the same Event to


discard the current row and Stops the fetching with next rows.
Write the Below Code in RowSelect
If Year(SALARY_DTLS.PAY_END_DT.Value) = 2001 Then
DiscardRow();
StopFetching();
End-If;
Out of 3 rows, only 2000 row will be fetched into Component Buffer.
PreBuild
When is it fired?
PreBuild event fires before the rest of the component build events.
What is the Use?

To change the Properties of the Component and Component Fields.


To Hide or Unhide Pages.
To define the Global or Component Variables.
The PreBuild event is also used to validate data entered in the Search
Dialog, after a prompt list is displayed.
What are the Restrictions?
PreBuild PeopleCode is only associated with components.
Examples?
Write the below code in PreBuild Event.
If %UserId <> "PS" Then
GetPage(Page.C_SALARY_DTLS).Visible = False;
C_WRK.PUSH_BTN.Enabled = False;
End-If;
If the PS User login to the Application, then Salary Details page and the
Push Button will be visible.
If any other User login to the system, they cant able to see the Salary
Details page and Push Button.

FieldDefault
When is it fired?
When new data is being added to the Component.
When a new row is inserted into a Scroll.
What is the Use?
To assign the default values to the field programmatically.
Contains meaningful values in the field rather than just leaving the field
blank.
Data Entry becomes easy.
What are the Restrictions?
FieldDefault Event fires only in Add Mode and when a new row is inserted
into a Scroll.
If the default value is assigned in the Record field properties then the
system won't execute the PeopleCode. Record field properties will override
the PeopleCode.
An Error or Warning issued from FieldDefault PeopleCode will cause a
runtime error and force cancellation of the component.
Examples?
Write the below code in COMPRATE FieldDefault Event.
SALARY_DTLS.COMPRATE.Value = 10000;
Then a new row being added to the component, a default value 10000 will
be assigned to COMPRATE.

FieldFormula
When is it fired?
FieldFormula Event fires for each and every User Actions (Except Save).
Fires for every field on every row in Component Buffer.
What is the Use?
Useful for basic Calculations.
Useful to write the User Defined Functions in the functional libraries
(FUNCLIB_ record definitions).
What are the Restrictions?
PeopleSoft recommends that not to use FieldFormula Event. It is much
earlier version of PeopleCode Event and not used in recent applications.
Instead write the code in RowInit and FieldChange Events.
Even PeopleSoft has minimized the use of this PeopleCode event in its
standard products.
RowInit
When is it fired?
The RowInit event fires the first time the Component Processor encounters a
row of data. And runs every time a new row of data loads into a Page.
This occurs during Component Build Processing and When user Insert a child
Row.
It also occurs after a Select or SelectAll RowSet method, or a ScrollSelect or
related function is executed.
RowInit PeopleCode is executed once for each row of data in the scroll area.
For example, if a Page is having a Scroll at Level 1 with 10 rows of data.
Then RowInit fires 11 times. Once for Level0 and 10 times for Level1.
What is the Use?
It is used for setting the initial state of Component Controls.
The purpose of RowInit PeopleCode is to complete initialization of data on
the row after it has been read from the database.
What are the Restrictions?
RowInit is not field-specific, it triggers on all fields and on all rows in the
Component Buffer.
Do not use ERROR or WARNING statement in RowInit PeopleCode, this
causes a runtime error and forces the end-user to cancel the component.
Applications that run on the PeopleSoft portal, external, dynamic hyperlink
information must be placed in RowInit PeopleCode. If it's placed in
FieldChange PeopleCode, it won't work.
Dont write the code which is Page Specific in RowInit rather write in Page
Activate.
Examples?
PostBuild
When is it fired?
The PostBuild event fires only after all the other component build events
have been fired.
What is the Use?
To change the Properties of the Component and Component Fields.
To Hide or Unhide Pages.
To define the Component Variables.
The PostBuild event is also used to validate data entered in the Search
Dialog, after a prompt list is displayed.
What are the Restrictions?
PostBuild PeopleCode is only associated with components.
Examples?
Activate
When is it fired?
Activate PeopleCode event fires every time the Page gets activated.
It also fires when the user tabs between the Pages in a Component.
What is the Use?
Activate Event used for Security Validations: such as, enabling a field or
hiding a Scroll.
What are the Restrictions?
This event is only valid for Standard or Secondary, not supported for Sub
Pages.
Activate PeopleCode can only be associated with Pages.
Examples?
Write the below code in Activate Event.
If %UserId <> "PS" Then
C_WRK.PUSH_BTN.Enabled = False;
End-If;
If the PS User login to the Application, PS can able to see the Push Button.
Other Users cant see it.

FieldEdit
When is it fired?
The FieldEdit event fires when the value of a specific Field / Row Just
changed.
What is the Use?
Useful to add more validations in addition to the System validations.
What are the Restrictions?
FieldEdit PeopleCode can be associated with Record Fields and Component
Record Fields.
If the validations requires for specific fields then use FieldEdit PeopleCode, if
the validations requires for across the Page fields then use SaveEdit.
Examples?
Write the below code in FieldEdit Event.
IF C_SALARY_DTLS.COMPRATE.VALUE > 800000 THEN
ERROR (MSGGETTEXT(30000, 3, "COMPRATE SHOULD NOT BE >
800000."));
END-IF;
If any characters entered into Number filed then system will take care and
will throw an Error Message.

If any value entered > 800000 then FieldEdit PeopleCode get fired and will
throw an Error Message.
FieldChange
When is it fired?
The FieldChange event fires when the value of a specific Field / Row Just
changed after FieldEdit fires.
Unless the FieldEdit executes, FieldChange will not execute.
What is the Use?
To assign the calculated values by programmatically.

To recalculate the values.


To change the properties of the other field based on one field.
What are the Restrictions?
It is not used for Validation.
Do not use Error or Warning statements in FieldChange PeopleCode, these
statements causes a runtime error that forces the end-user to cancel the
Page without saving the changes.
FieldChange PeopleCode can be associated with Record Fields and
Component Record Fields.
Examples?
Write the Code in USERID FieldChange.
SQLEXEC("SELECT NAME FROM PS_NAMES WHERE EMPLID = (SELECT
EMPLID FROM PSOPRDEFN WHERE OPRID = :1)", %USERID, &NAME);
SALARY_DTLS.NAME.VALUE = &NAME;
Once the user enters the UserID, then Name will be populated
automatically.
When is it fired?
The PrePopUp event fires just before the display of a Pop-Up Menu.
What is the Use?
PrePopUp PeopleCode useful to Hide Menu Item, Enable Menu Item.
What are the Restrictions?
PrePopUp PeopleCode can be associated with record fields and component
record fields.
Examples?
Create a Popup Menu.
File New Menu Select Popup Menu
Add a Menu Item.
Double Click on the Menu Item
Give the Menu Item Name as JOB_DATA.
Label as Job Data.
Type as PeopleCode.
Click on OK
Write the PeopleCode on ItemSelected Event.
Right Click on the Job Data Menu Item and View PeopleCode.
Write the code in ItemSelected Event.
Transfer( False, @("MenuName.ADMINISTER_WORKFORCE_(GBL)"),
BarName.USE, ItemName.JOB_DATA, Page.JOB_DATA1, "U");
Add another Menu Item POSITION_DATA
Write the code in ItemSelected Event.
Transfer( False, MenuName.MANAGE_POSITIONS, BarName.USE,
ItemName.POSITION_DATA, Page.POSITION_DATA1, "U");
Add another Menu Item USERPROFILES
Write the code in ItemSelected Event.
Transfer( False, MenuName.MAINTAIN_SECURITY, BarName.USE,
ItemName.USERPROFILES, Page.USER_GENERAL, "U");
Save the Popup Menu as TEST_POPUPMENU
Create a New Page, Insert a New filed (TEST_WRK.ABC), Go to Page Field
Properties Use tab assign the Popup Menu as TEST_POPUPMENU.
Assign the value to TEST_WRK.ABC Field in Page Activate.
TEST_WRK.ABC.value = Popup Menu;
Popup Menu appears When We open the Page in PIA

When we click on Popup Menu Icon, 3 Menu Items will be displayed.

We can Hide or Unhide the Menu Items by writing the PeopleCode in


PrePopUp Event of TEST_WRK.ABC field.
HideMenuItem(MenuName.CNU_POPUPMENU, ItemName.JOB_DATA);
Job Data Menu Item will not be visible in the Page.

ItemSelected
When is it fired?
The ItemSelected event fires whenever the end-user chooses Menu Item
from a Popup Menu.
What is the Use?
Mainly useful to transfer to other Pages.
What are the Restrictions?
ItemSelected PeopleCode is only associated with pop-up menu items.
This event, and all its associated PeopleCode, does not fire if run from a
Component Interface.
RowInsert
When is it fired?
RowInsert event fires when a new row of data inserted.
What is the Use?
To assign default values.
To restrict the users from inserting new rows.
What are the Restrictions?
RowInsert PeopleCode can be associated with record fields and component
records.
Do not put PeopleCode in RowInsert that already exists in RowInit, because
a RowInit event always fires before the RowInsert event, which will cause
your code to be run twice.
Do not use Error or Warning statements in RowInsert PeopleCode, this will
cause a runtime error and force cancellation of the component.
RowInsert does not trigger PeopleCode on Derived/Work fields.
Examples?
Write the below code in RowInsert Event of PAY_END_DT field.
SALARY_DTLS.PAY_END_DT.Value = %Date;
When we Add new row, current date will be assigned to Pay End Date.

RowDelete
When is it fired?
Row Delete event fires when a user deletes a row of data.
What is the Use?
To restrict some users to delete rows from the Scrolls.
To recalculating the field values.
After a Row Delete, FieldDefault and FieldFormula will be executed.
What are the Restrictions?
It is valid only if the component is having Scrolls (means child records). The
program never executes unless there is Scrolls, not valid for 0 level records.
Examples?
SaveEdit
When is it fired?
The SaveEdit Event will fire When we click the Save button.
What is the Use?
Useful to validate the data.
It works same as FieldEdit.
It increases the performance of the program as it validates more than one
field values.
What are the Restrictions?
SaveEdit is not field-specific. It fires for every row of data in the Component
Buffers.

Examples?
SavePreChange
When is it fired?
SavePreChange fires after SaveEdit completes without errors.
What is the Use?
SavePreChange PeopleCode gives you one last chance to manipulate data
before the system updates the database.
If SavePreChange runs successfully, a Workflow event is generated, and
then the Component Processor issues appropriate INSERT, UPDATE, and/or
DELETE SQL commands.
It will not commit the database. After SavePreChange data will be available
in Component Buffer as well as uncommitted data in Database.
What are the Restrictions?
SavePreChange is not field-specific: it triggers PeopleCode on all fields and
on all rows of data in the Component Buffer.
SavePreChange PeopleCode can be associated with record fields,
components and component records.
Dont use WinMessage in this event.
Examples?
.
Workflow
When is it fired?
Workflow PeopleCode fires immediately after SavePreChange and before the
database updates.
What is the Use?
Useful to do the Workflow related Processing.
Under this event we can write the PeopleCode that is only related to
workflow such as TriggerBusinessEvent.
What are the Restrictions?
Workflow PeopleCode is not field-specific: it triggers PeopleCode on all fields
and on all rows of data in the Component Buffer.
Examples?

SavePostChange
When is it fired?
SavePostChange event fires After the Component Processor updates the
database.
The system issues a SQL Commit after SavePostChange PeopleCode
completes successfully.
What is the Use?
Use SavePostChange PeopleCode to update tables that are not in the
currently active component, based on the new values that were just updated
in the database.
What are the Restrictions?
Avoid Errors and Warnings in this event.
Dont use SQLExec to commit or Rollback the database manually, let the
Component Processor issue these SQL commands.
SavePostChange PeopleCode is not field-specific: It triggers PeopleCode on
all fields and on all rows of data in the Component Buffer.
SavePostChange PeopleCode can be associated with record fields,
components, and component records.
Examples?
.
Message
When is it fired?
.
What is the Use?
Message PeopleCode is associated with a message definition.
We can access the message PeopleCode by right click on the message object
in the project workspace.
Associated events are
1. OnPublishTransform Event

Examples?
SavePreChange
When is it fired?
SavePreChange fires after SaveEdit completes without errors.
What is the Use?
SavePreChange PeopleCode gives you one last chance to manipulate data
before the system updates the database.
If SavePreChange runs successfully, a Workflow event is generated, and
then the Component Processor issues appropriate INSERT, UPDATE, and/or
DELETE SQL commands.
It will not commit the database. After SavePreChange data will be available
in Component Buffer as well as uncommitted data in Database.
What are the Restrictions?
SavePreChange is not field-specific: it triggers PeopleCode on all fields and
on all rows of data in the Component Buffer.
SavePreChange PeopleCode can be associated with record fields,
components and component records.
Dont use WinMessage in this event.
Examples?
.
Workflow
When is it fired?
Workflow PeopleCode fires immediately after SavePreChange and before the
database updates.
What is the Use?
Useful to do the Workflow related Processing.
Under this event we can write the PeopleCode that is only related to
workflow such as TriggerBusinessEvent.
What are the Restrictions?
Workflow PeopleCode is not field-specific: it triggers PeopleCode on all fields
and on all rows of data in the Component Buffer.
Examples?

SavePostChange
When is it fired?
SavePostChange event fires After the Component Processor updates the
database.
The system issues a SQL Commit after SavePostChange PeopleCode
completes successfully.
What is the Use?
Use SavePostChange PeopleCode to update tables that are not in the
currently active component, based on the new values that were just updated
in the database.
What are the Restrictions?
Avoid Errors and Warnings in this event.
Dont use SQLExec to commit or Rollback the database manually, let the
Component Processor issue these SQL commands.
SavePostChange PeopleCode is not field-specific: It triggers PeopleCode on
all fields and on all rows of data in the Component Buffer.
SavePostChange PeopleCode can be associated with record fields,
components, and component records.
Examples?
.
Message
When is it fired?
.
What is the Use?
Message PeopleCode is associated with a message definition.
We can access the message PeopleCode by right click on the message object
in the project workspace.
Associated events are
2. OnPublishTransform Event
3. OnSubscribeTransform Event
4. OnRouteSend Event
5. OnRouteReceive Event
6. OnRequest Event
OnRouteSend Event is for publishing purpose.
OnRouteReceive, OnRequest Event and OnSubscribeTransform Event are for
Subscribe Purpose.
What are the Restrictions?
.
Examples?
.
OnExecute

Methods
Questions about Events
General:
31. What are the Component Build Processing Events in Search
Mode?
RowSelect, PreBuild, RowInit, PostBuild.
32. What are the Component Build Processing Events in Add Mode?
PreBuild, FieldDefault, RowInit, PostBuild
33. In which events we can write the Error and Warning Messages?
FieldEdit, SaveEdit, RowSelect, RowDelete, SearchSave.
34. In which events Warning Statement is not allowed?
FieldDefault, FieldFormula, RowInit, FieldChange,RowInsert, SavePreChange,
SavePostChange
35. Where can we write UPDATE, INSERT, and DELETE statements?
Only In FieldChange, SavePreChange, SavePostChange, Workflow events.
36. In which situation we will write the code in Component Record
Field level?
If the record is used in multiple components and if we wanted to execute to
a specific component then will write that code in the Component Record Field
Level.
We can also write the same code in Record Field level too but we have to
evaluate the component and put that code inside the condition so that the
code fires when we access the record thru a specific component not for all
other components.
FieldDefault
37. How many ways we can assign Default value to a field?
We can assign default values in 2 ways.
1. Record Field Properties.
2. FieldDefault PeopleCode Event.
38. A default value 10 is assigned to a field at Record Field property
and Value 15 assigned at FieldDefault Event. So finally which values
will it hold?
10. If the default value is assigned in the Record field properties then the
system won't execute the PeopleCode. Record field properties will override
the PeopleCode.
39. A default value 10 is assigned to a field at Component Record
Field Level and 15 at Record Field Level. So finally which values will
it hold?
10, as Record level PeopleCode fires first 15 will assign then Component
Record Level code will fires So 10 will be replaced the existing value.
40. What are the Disadvantage/Advantages of assigning a default
value thru Record Field Properties?
Based on the conditions we cant assign default values.
Default value remains same in all the components wherever it is referred.
41. A record is having 2 fields with 3 rows.
NAME NUMBER
ABC 100
PQR 200
XYZ 300
Assume there is a Default value 500 assigned to Number field on
FieldDefault Event.
What value will be assigned when you select PQR row and opens the
Page?
FieldDefault will not be get fired in Search Mode.
42. In the above Example, What happens if we assign the value in
RowInit?
500 will be assigned.
43. What makes the difference when we assign a default value in
RowInit and FieldDefault?
RowInit:
Default value will be Assigned in both the Search and Add Modes.
Also default value will be assigned When you add a row in Scroll.
FieldDefault:
Default value will not be assigned when you go thru Search Mode.
Only in Add Mode, Default value will be assigned.
Also when you add a new row in Scroll, default value will be assigned.
44. Assume a value 10 is assigned at FieldDefault Event and 20 at
RowInit. When you add a New row from the search page, what value
will be get assigned?
First 10 will be assigned as FieldDefault executes first and then 10 will be
replaced by 20.
FieldEdit
45. Which events will be useful to do the Validations?
SearchSave validates the data entered in the search dialog box.
FieldEdit validates a single field, when the field value is changed.
SaveEdit performs cross-validation on two or more fields during save
processing.
46. Assume a field is having value 10. If we delete that value and
assign value 10 again back to it. Will FieldEdit executes?
No, FieldEdit and FieldDefault will not be get fired.
FieldChange
47. Can we do the validations in FieldChange?
No, not recommended. Instead use FieldEdit for validation purpose.
48. What are the events get fired when there is a change in field
value?
FieldEdit and FieldChange.
49. What is the Difference between FieldEdit and FieldChange?
FieldEdit FieldChange
Useful to
recalculate field
Useful to validate
values based on
the code.
changes made to
other fields.
Error and Warning
Dont use for
statements can be
validation
handled in
purpose.
FieldEdit.
50. What events get fired when you click on a Radio Button / Check
Box / Push Button / Hyperlink?
FieldEdit and FieldChange.
51. If there is any change in the value to either A or B fields then C
value should be changed. (C = A + B). Where to write the Code to
change the C value?
FieldChange of A and B.
FieldFormula
52.

SearchInit
53.

SearchSave
54.

RowSelect
55.

PreBuild
56. What happens when there is an error found in PreBuild?
It sends back the user to the Search Page.
57. Assume there is no Search Page for a Component and an error
found in PreBuild event then what happens?
A Blank component page will be displayed.
RowInit
58. Which events will be useful to do the Calculations?
For calculations, we would normally use RowInit, FieldChange, and
RowDelete.
59. Which events will be useful to set the display characteristics?
RowInit and FieldChange.
PostBuild
60. Whats the difference between PreBuild and PostBuild?
PreBuild PostBuild
The PreBuild event The PostBuild
fires before the event fires after all
rest of the the other
component build component build
events. events have fired.
PreBuild can be
used to validate
your search data,
discarding rows as
PreBuild is the first
component event
which triggers first.

Activate
61. Assume you have made some changes in a Page, what happens
when you click on Next in List or Previous in List Buttons without
save?
It prompts the end-user to Save the Component.
62. A Page is having 2 levels, level 0 and level 1 (Scroll). There is a
field at level 1. I wanted hide that field for all the users, where will
you write the PeopleCode?
Page Activate and Row Init.
SaveEdit
63. What is the Difference between FieldEdit and SaveEdit?
Both used for validation, but performed at a different time.
FieldEdit SaveEdit
FieldEdit get fired SaveEdit get fires
when the User when the user
changes a field Saves the
value. Component.
FieldEdit Performs SaveEdit Performs
on one row of on every row of
data. data.
When there is an
In SaveEdit field
error occurs field
will not turns red.
turns to red.
If the Page is in
Whichever the
deferred mode,
mode it is,
FieldEdit will not
SaveEdit will be
fire; All the
fired when user
FieldEdits will fire
clicks on Save
once when we click
Button.
on Save button.
64. Assume some validations are there in SaveEdit. Open the page in
PIA, and click on Save Button without changing any value, will the
SaveEdit code gets fired?
No, unless there is a data which needs to be saved in the database, No Save
actions will be get fired.
SavePreChange
65. After which Event database will be get updated?
After SavePreChange / Workflow Event. Just updates the Database but not
commits.
Workflow
66. Assume there is TriggerBusinessEvent PeopleCode exists in
Workflow event which sends the mail to the user. What happens if
something got errored out in SavePostChange Event?
It triggers the mail.
67. When Workflow even gets fired?
After SavePreChange.
SavePostChange
68. How does SavePostChange differ from all other PeopleCode
events?
SavePostChange is different from all other PeopleCode events as it is
performed after the updates are made on the database.
69. Whats the difference between SavePreChange and
SavePostChange?
SavePreChange SavePostChange
SavePreChange
provides one last
SavePostChange
chance to
occurs after the
manipulate data
system updates
before the
the database.
database is
updated.
During
During
SavePreChange
SavePreChange
Event execution,
Event execution,
data will be
data will be
available only in
available only in
Component Buffer
Component Buffer.
and the Database.
70. After which Event Component Buffers will be get cleared?
After SavePostChange.
71. When the database will be get Committed?
After SavePostChange.
72. Assign a value 10 to a field in SaveEdit, 20 in SavePreChange, and
15 in SavePostChange for the same field. Finally when you save the
page, what value will be get updated in the database?

RowInsert
73. In Search Mode, You have selected a search key value and
entered into the page - What are the events get fired when you add
a new row in Scroll? (When you click on + button)

74. In Add Mode, You have given a new key value and entered into
the page - What are the events get fired when you add a new row in
Scroll? (When you click on + button)

75. What events will be get fired when you Add a row?
FieldDefault, RowInit, RowInsert.
RowDelete
76. In Search Mode, You have selected a search key value and
entered into the page - What are the events get fired when you
delete a row in Scroll? (When you click on - button)
77. In Add Mode, You have given a new key value and entered into
the page - What are the events get fired when you delete a row in
Scroll? (When you click on - button)

78. What events will be get fired when you delete a row?

79.

PrePopUp
80.

ItemSelected
81.

PeopleCode Language
Functions
82. About PeopleCode Functions?
Function definitions must be placed at the top of the program.
Functions can be called from another program; in that case they need to be
declared at the top of the program where they are called.
83. About Internal Functions?
Internal functions are the functions which are defined and used in the same
Event.
No need to declare Internal Functions.
84. About External Functions?
External Functions are the functions which are defined in one event and used
in other event.
External PeopleCode functions are stored in records whose names begin in
FUNCLIB_, and they are always placed in the FieldFormula event.
Write in Record Field Level FieldFormula not in Component Record Field
Level.
85. Where the Internet Scripts will be stored?
In FieldFormula of event of any record which starts with WEBLIB_.
86. How to create the functions?
FUNCTION <FUNCTION NAME> [(PARAMLIST)] [RETURNS DATA_TYPE]
[STATEMENTS]
END-FUNCTION
Use the Function Key word followed by the Function Name and parameters
list and Returns data type.
And each function should end with End-Function Key word.
Function name can be up to 100 characters in length.
87. How to declare the functions?
Using the Key word Declare.
DECLARE FUNCTION <FUNCTION NAME> PEOPLECODE
<RECORD_NAME.FIELD_NAME> <EVENT_TYPE>
88. Is it required to declare the functions before using it?
When a function is declared it will be loaded into memory so that it can be
used multiple times whenever it required.
If the function is internal, no need to declare it.
To use an external function, it should be declared at the top.
89. How to call the External Functions?
An external program is called by using the name of the external function
and an exact count of parameters enclosed in parenthesis.
The parameter names in the call do not have to match the names used in
the actual external PeopleCode function.
Parameters must be passed in the same order.
90. Can functions return a value?
Yes functions may return a value, while calling any function we have to
assign it to any variable so that it stores the returned value.
Functions can return any of data types like Number, String, Boolean, Date,
Time, DateTime, Any.
91. What are External Non-PeopleCode Functions?
Some times internal PeopleCode functions may not meet the user
requirement. In that case PeopleSoft allows us to create functions in other
languages like C called it as DLL Libraries. To Use these libraries it needs to
be Declared.
Data Types
92. What are the Data Types available in PeopleCode?
1. Conventional: Useful to create the user defined functions.
NUMBER, FLOAT, INTEGER, STRING, DATE, TIME, DATETIME, ANY,
BOOLEAN, OBJECT.
2. Object Oriented: useful to instantiate objects from that class.
Field, Record, Row, RowSet (Data Buffer Access Types)
Grid, GridColumn, Page (Page Display Types)
Operators
93. What are the Operators available in PeopleCode?
1. Mathematical Operators:
+, -, *, /, **
2. Relational Operators (Comparison Operators):
<, >, =, >=, <=, !=, <>
3. Boolean Operators:
NOT, AND, OR
4. String Concatenation:
|
5. Operations on Dates and Times:
6. @ Operator:
@ Operator converts a string value to the Definition Type.
@ will be used when we wanted to create a Object whose name is unknown
when the PeopleCode is written.
Ex:
&RECNAME = "RECORD." | Upper(&RECNAME);
&REC = CreateRecord(@ &RECNAME);
Control Statements
94. What are the Control Statements Available in PeopleCode?
1. Branching / Conditional Statements:
IF/THEN/ELSE
If <Condition>
then
PeopleCode
Statements;
Else
PeopleCode
Statements;
End-If;
Evaluate
Evaluate <Field or
Variable>
When = <Value1>
PeopleCode
Statements;
Break;
When = <Value1>
PeopleCode
Statements;
Break;
When-other
PeopleCode
Statements;
End-Evaluate;

Evaluate &Number
When >=1 and
<=100
PeopleCode
Statements;
Break;
When >=101 and
<=200
PeopleCode
Statements;
Break;
End-Evaluate
2. Looping Statements:
For
FOR <&VARIABLE> = <START-VALUE>
TO <END-VALUE> [STEP <STEPVALUE>]
STATEMENT1;
STATEMENT2;
END-FOR;
While
While <Condition>
Statement1;
Statement2;
End-While;
Repeat Until
Repeat
Statement1;
Statement2;
Until <Condition>;
Repeat
Statement1;
Statement2;
Until <Condition>;
95. Continue function?
Use the Continue statement to continue execution in a loop.
In For loops, this statement continues to do the next step of the iteration
In While loops, this statement continues to the top of the loop and the test
of the condition
In Repeat-Until loops, this statement continues to the Until check at the
bottom of the loop.
96. About EXIT function?
Immediately issues the Rollback and terminates the current event and
executes the next events.
97. About Break?
Terminates the execution of a Loop or Evaluate function.
98. Throw
99. Try
100. Create Exception

101. Catch Exception

You might also like