You are on page 1of 186

PeopleSoft

Application Services

PeopleCode Events

1
PeopleTools

PeopleSoft applications are designed using the
powerful tools provided by PeopleSoft:
 Application Designer
 PeopleCode
 Application Engine
 PeopleCode is a 4GL and has a rich syntax and
structure to develop & incorporate complex
application logic

2
PeopleCode
 PeopleCode is simple but yet high-powered language to
satisfy complex business requirements within PeopleSoft.

 It is used to incorporate sophisticated business rules


into PeopleSoft Applications.

 The language is designed specially to interact with the


application processor, giving the capability to enhance
the application beyond the capability of the PeopleTools.

 Using PeopleCode virtually any edit or validation can be


accomplished.

3
PeopleCode Events
 PeopleSoft uses “Events” to control the flow and
functionality of the application
 PeopleCode Programs are attached to the events supported
by PeopleSoft

 Here, we will be focusing only on PeopleCode


Events, and how, why, where and when these
“Events” could be used for developing Powerful
Applications.

4
PeopleCode Events – High Level Flow
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit

RowSelect SaveEdit
FieldChange

PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

Insert Delete
PostBuild
RowInsert RowDelete

5
PeopleCode Event - SearchInit Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit

RowSelect SaveEdit
FieldChange

PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

Insert Delete
PostBuild
RowInsert RowDelete

6
PeopleCode Events

SearchInit

When is it fired?

 This event is generated just before search dialog, add


dialog or data entry dialog box is displayed.

7
PeopleCode Events

SearchInit

Where is it used?
 SearchInit can be associated with record fields and
component search records.

8
PeopleCode Events

SearchInit

What is it used for?

 SearchInit event triggers associated PeopleCode in the


search key fields of the search record.

9
PeopleCode Events

SearchInit
Restrictions
 SearchInit will not trigger if run from a component interface
 Can’t use functions like DoModal,

DoModalComponent,Transfer,TransferPage in
SearchInit event.

10
PeopleCode Events

SearchInit event
Example

 This PeopleCode in SearchInit event on component search key


record field EMPLID sets the search key page field to the user’s
employee ID, makes the page field unavailable for entry, and
enables the user to modify the user’s own data in the component.
EMPLID=%EmployeeId;
Gray (EMPLID);
AllowEmp1IdChg(true);

11
SearchInit Event

This code is to directly go to the record where employee number is


10100

12
SearchInit Event

13
SearchInit Event

This code will displays the page which


contains the employee details of the
person whose Employee Number is
10010.

14
SearchInit Event

15
PeopleCode Event - SearchSave Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit

RowSelect SaveEdit
FieldChange

PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

Insert Delete
PostBuild
RowInsert RowDelete

16
PeopleCode Events

SearchSave

When is it fired?
 To control processing after search key values are
entered, but before the search based on these keys is
executed.

17
PeopleCode Events

SearchSave

Where is it used?
 SearchSave PeopleCode can be associated with record
fields and component search records.

 SearchSave PeopleCode is executed for all search key


fields on a search dialog, add dialog, or data entry dialog
box after the end-user clicks search.

18
PeopleCode Events

SearchSave
What is it used for?
 The typical use of this feature is to provide cross-field edits for
selecting a minimum set of key information.

 It is also used to force user to enter a value in at least one field,


even if it’s a partial value to help narrow a search for tables with
many rows.

 We can use Error and Warning statements in SearchSave


PeopleCode to send the end-user back to the search dialog box if
the end-user entry doesn’t pass validations implemented in the
PeopleCode.

19
PeopleCode Events

SearchSave

Restrictions
 SearchSave does not fire when values are selected from
the search list.

 This event, and all it’s associated PeopleCode, will not fire
if run from a component interface.

20
SearchSave event

This code displays an error message


when the user leaves the employee
number field blank

21
SearchSave event

Employee number is blank

Error message displayed.

22
PeopleCode Event - RowSelect Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

23
PeopleCode Events

RowSelect Event

 The RowSelect event fires at the beginning of the


Component Build process in any of the Update action
modes (Update, Update/Display All, Correction).
 RowSelect PeopleCode is used to filter out rows of
data as they are being read into the component buffer.
 This event also occurs after a ScrollSelect or related
function is executed.

24
PeopleCode Events

RowSelect

When is it fired?
 The RowSelect event fires at the beginning of the Component Build
process in any of the Update action modes (Update, Update/Display
All, Correction).

25
PeopleCode Events

RowSelect

Where is it used?
 RowSelect PeopleCode is used to filter out rows of data
as they are being read into the component buffer.

26
PeopleCode Events

RowSelect
What is it used for?
 A DiscardRow function in RowSelect PeopleCode causes the
Component Processor to skip the current row of data and continue
to process other rows.
 A StopFetching statement causes the Component Processor to
accept the current row of data, then stop reading additional rows. If
both statements are executed, the program skips the current row of
data, then stops reading additional rows.

27
PeopleCode Events

RowSelect

Restrictions
 In RowSelect PeopleCode, you can refer to record fields
only on the record that is currently being processed

 This event, and all it’s associated PeopleCode, will not fire
if run from a Component Interface.

28
PeopleCode Events

RowSelect
Row Select Processing
 Row Select processing enables PeopleCode to filter out rows of data
after they have been retrieved from the database server using a
SQL Select statement and before they are copied to the component
buffers.

 Row Select processing is a subprocess of component build


processing in add modes. It also occurs after a ScrollSelect or
related function is executed.

29
RowSelect Event

30
RowSelect Event

We are selecting the record whose


employee number = 10020

31
RowSelect Event

Record has been displayed

32
RowSelect Event

This code discard the rows whose department ID = DEPT1004


and the rows are not placed in the buffer

33
RowSelect Event

Trying to discard the row whose


department Id is DEPT1004 .

Here the Employee Number 10020 is


associated with DEPT1004.

34
RowSelect Event

Since the row is not placed in the buffer


the details regarding the employee ID = 10020 are not displayed

35
PeopleCode Event - PreBuild Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

36
PeopleCode Event

PreBuild Event

 This event is often used to hide or unhide pages. It’s


also used to set component variables

37
PeopleCode Event

PreBuild Event

When is it fired?

 The PreBuild event fires before the rest of the


component build events

38
PeopleCode Event

PreBuild Event

Where is it used?

 PreBuild PeopleCode is only associated with


components.

39
PeopleCode Event

PreBuild Event

What is it used for?

 The PreBuild event is also used to validate


data entered in the search dialog, after a
prompt list is displayed
 It is used to hide or unhide pages.

40
PreBuild Event

Note that the DeptPage tab is visible


which allow the user to navigate to that page

41
PreBuild Event

This code hides the department page to the user = VP1

42
PreBuild Event

Selecting a record to view the data

43
PreBuild Event

The DeptPage Tab is not visible.


The Deptpage cannot be viewed by the
user whose userid= VP1

44
PeopleCode Event - FieldDefault Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

45
PeopleCode Events

FieldDefault Event
 The FieldDefault PeopleCode event enables you to
programmatically set default values to the fields when
they are initially displayed.

 FieldDefault PeopleCode normally sets fields to


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.

46
PeopleCode Events

FieldDefault

When is it fired?
 This event is fired on all page fields as part of many different
processes; however it triggers PeopleCode programs only when the
following conditions are all true:

1. The page field is still blank after applying any default


specified in the record field properties. (This will be true if there is
no default specified, if a null value is specified, or if a 0 is specified
for a numeric field.)

2. The field has a FieldDefault PeopleCode program.

47
PeopleCode Events

FieldDefault

Where is it used?

 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.

48
PeopleCode Events

FieldDefault

What is it used for?


 If a field value is changed, whether through PeopleCode or by an
end-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, that is, if a value is set in FieldDefault or
FieldFormula, the row is not marked as changed

49
PeopleCode Events

Advantages of field default:


 Data Entry becomes easy.
 Contains meaningful values in the field rather than just
leaving the field blank.

50
PeopleCode Events

FieldDefault

Restrictions

 An Error or Warning issued from FieldDefault


PeopleCode will cause a runtime error and force cancellation
of the component.

51
FieldDefault Event

This code sets the default value of


employee salary field to 25000

52
FieldDefault Event

The default value of


employee salary is
set to 25000

53
PeopleCode Event - FieldFormula Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

54
PeopleCode Events

FieldFormula Event

 The FieldFormula event is a vestige of much earlier


versions of PeopleTools, and is not used in recent
applications, the RowInit and FieldChange events are
used rather than FieldFormula.

 FieldFormula is generally used for any type of


Calculations.

55
PeopleCode Events

FieldFormula

When is it fired?
 FieldFormula PeopleCode fires in many different
contexts and triggers PeopleCode on every field on
every row in the component buffer, it can seriously
degrade the performance of your application.

56
PeopleCode Events

FieldFormula

Where is it used?

 As a matter of convention, FieldFormula is now often


used in FUNCLIB_ (function library) record definitions to
store shared functions.

57
PeopleCode Events

FieldFormula

What is it use for?


 FieldFormula is used for basic calculations.

58
PeopleCode Events

FieldFormula

Restrictions
 Do not use FieldFormula PeopleCode in your
components.

 Use it only to store external PeopleCode functions in FUNLIB_


record definitions.

59
FieldFormula Event

Initializing the default value to When user enters a value


25000 in FieldDefault event less than 25000 it displays an
error message

60
FieldFormula Event

Default value is 25000

61
FieldFormula Event

When user tries to enter


employee salary
less than 25000,
An error message is displayed.

62
PeopleCode Event - RowInit Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

63
PeopleCode Events

RowInit

When it is fired?
 The RowInit event fires the first time the component
Processor encounters a row of data.

64
PeopleCode Events

RowInit
Where is it used?
 It is used for setting the initial state of Component Controls.

 RowInit is not field-specific, it triggers on all fields and on all rows in


the component buffer.

 This occurs during component build processing and row insert


processing.

 It also occurs after a Select or SelectAll Rowset method, or a


ScrollSelect or related function is executed.

65
PeopleCode Events

RowInit

What is it used for ?


 The RowInit 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.

 RowInit not getting triggered isn’t considered to be an error

66
PeopleCode Events

RowInit
Restrictions
 Do not use “ERROR” or “WARNING” statement in RowInit
PeopleCode, this causes a runtime error and forces the end-user
to cancel the component.
Code in FieldChange event would not be executed if
 The Record is at level 0.
 Every record field that is present in the data buffer is also
present in the keys for the component.
 Every record field that is present in the data buffers is
display only.
 RowInit is often paired with FieldChange PeopleCode .
 The component processor runs RowInit PeopleCode when it
loads record from the database. However, in some cases, the
record can be initialized entirely from the keys for the
component. when this happens, RowInit PeopleCode isn’t
executed.

67
PeopleCode Events

RowInit

Example
 Suppose you have a field called PRODUCT.
 The value of PRODUCT is field A * field B.
 When component is initialized or new row is inserted, we use
RowInit PeopleCode to initialize PRODUCT equal to A*B .
 We could then attach FieldChange PeopleCode programs to both
A and B which also set PRODUCT equal to A*B.
 Whenever end user changes the value of either A or B,PRODUCT
would be recalculated

68
RowInit Event

This code is used to generate employee number automatically


once the add button is clicked

69
RowInit Event

The user need not enter the Employee number.


It is automatically generated and has been made
“display only” , the user cannot change the value.

70
PeopleCode Event – PostBuild Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

71
PeopleCode Events

PostBuild Event
 The PostBuild event fires only after all the other
component build events have been fired

 This event is often used to hide or unhide pages.

 It’s also used to set component variables.

72
PeopleCode Events

PostBuild

When is it fired?
 The PostBuild event fires after all the other component
build events have fired.

73
PeopleCode Events

PostBuild

Where is it used?
 This event is often used to hide or unhide pages.

74
PeopleCode Events

PostBuild

What is it used for?


 It’s also used to set component variables.

 PostBuild PeopleCode is only associated with components.

75
PostBuild Event

This code is for collecting the information of a record – who created


the record and when ?

76
PostBuild Event

Saving it. After saving the record


Now we are adding a record the required details are captured.

77
PostBuild Event

These are the details regarding the record

78
PeopleCode Event – Activate Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

79
PeopleCode Event

Activate Event

 Activate event is to segregate the PeopleCode that is


related to a specific page from the rest of the
application’s PeopleCode.
 Each page has its own Activate event.

80
PeopleCode Event

Activate Event
When it is fired?

 The Activate event is fired each time the page gets


activated.

81
PeopleCode Event

Activate Event
Where is it used?
 Activate PeopleCode can only be associated with
pages.
 The Activate event triggers any Activate PeopleCode
associated with the page processing.

82
PeopleCode Event

Activate Event
What is it used for?
 The event used for security validation: such as,
enabling a field or hiding a scroll , enabling user to
programmatically control the display of that page
controls.
 This event is used for component Build Processing –
Add Mode and Update Mode

83
PeopleCode Event

Activate Event

Restriction

 This event is valid only for pages that are defined as


“Standard” or “Secondary”. This event is not
supported for “Subpages”

84
Activate Event

The user is allowed to see the Department page as Display Only

85
Activate Event

The fields are display only

86
PeopleCode Event – FieldEdit Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

87
PeopleCode Events

FieldEdit

When is it fired?
 The FieldEdit event fires on the specific field and row
that has just changed.

88
PeopleCode Events

FieldEdit
Where it is used?
 FieldEdit PeopleCode can be associated with record
fields and component record fields.

 FieldEdit PeopleCode is used to validate the contents of


a field, supplementing the standard system edits.

89
PeopleCode Events

FieldEdit

What is it used for?


 If the data does not pass the validation, the PeopleCode
program should display a message using the Error
statement, which redisplays the page, displaying an
error message and turning the field red.
 If you want to execute the field edit, but just want to
alert the end-user to possible problem, use a warning
statement instead of ERROR.

90
PeopleCode Events

FieldEdit

Restrictions
 If the validation must check the contents of more than
one field, that is, if the validation is checking for
consistency across page fields, then SaveEdit
PeopleCode can be used instead of FieldEdit.

91
FieldEdit Event

This code is to check whether the


Employee name is a valid one or not .
The name should not contain
numbers or any special characters
Other than white space.

92
FieldEdit Event

User is entering some special


character
in the Employee name field

When the user tries to select the Department ID, a win message
will be displayed.

93
FieldEdit Event

Message Box has been displayed

If the user clicks the “ok” button, the Emppage will be


displayed, allowing the user to edit the name field.

94
FieldEdit Event

This is peopleSoft
generated warning ,
explaining that name field
is not valid. Just click ok
button to edit the name
field.
95
FieldEdit Event

Here the user is


allowed to edit the
name field.

96
FieldEdit Event

Now the user is allowed to select the Department Id.

97
PeopleCode Event – FieldChange Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

98
PeopleCode Events

FieldChange

When is it fired?

 FieldChange PeopleCode can be associated with record


fields and component record fields
 The FieldChange event fires on the specific field and
row that has just changed

99
PeopleCode Events

FieldChange
Where is it used?
FieldChange PeopleCode is used to
 Recalculate field values.
 To change the appearance of page controls.
 To Process the result from FieldChange other
than the data validations.

100
PeopleCode Events

FieldChange
What is it used for?
 FieldChange PeopleCode is often paired with RowInit
PeopleCode.
 In RowInit / FieldChange, the RowInit PeopleCode
check the values in the component and initializes the
state or value of page controls accordingly.
 FieldChange PeopleCode then rechecks the values in
the component during execution and resets the state
or value of the page controls0.

101
PeopleCode Events

FieldChange
Restrictions
 It is not recommended to have Error or Warning
statement in FieldChange PeopleCode. It is suggested
that all data validation should be performed in FieldEdit

102
PeopleCode Events

FieldChange event
Example
 Suppose you have a field called PRODUCT.
 The value of PRODUCT is field A * field B.
 When component is initialized or new row is inserted,
user uses the RowInit PeopleCode to initialize
PRODUCT equal to A*B .
 User could then attach FieldChange PeopleCode
programs to both A and B which also set PRODUCT
equal to A*B.
 When ever user changes the value of either A or B,
PRODUCT would be recalculated.
103
FieldChange Event

This code automatically places the Employee name


once Employee number is selected.

104
FieldChange Event

Select the employee number

105
FieldChange Event

Employee name will be displayed automatically


once the Employee number is selected.

106
PeopleCode Event – PrePopup Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

107
PeopleCode Event

PrePopup Event

 The PrePopup PeopleCode event enables you


to disable, check, or hide menu items in the
pop-up.

108
PeopleCode Event

PrePopup Event

When is it fired?

 The PrePopup event fires just before the display of a


pop-up menu.

109
PeopleCode Event

PrePopup Event

Where is it used?
 PrePopup PeopleCode can be associated with record
fields and component record fields .

 PrePopup PeopleCode menu item operations (such as


HideMenuItem, EnableMenuItem, and so on) work
with pop-up menus attached to a grid, not a field in a
grid

110
PeopleCode Event

PrePopup Event

What is it used for?

 The PrePopup PeopleCode is used to control the


appearance of the Pop-up menu items.

111
PeopleCode Event

PrePopup Event
 PrePopup Processing

112
PrePopup Event

Three Menu Item Displayed before


the Event triggers.

113
PrePopup Event

This code is used to hide the menu item


“SAL” at the Run-Time.

114
PrePopup Event

Pop-Up Menu Icon

115
PrePopup Event

Selected Menu-Item is hidden

116
PeopleCode Event – ItemSelected Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

117
PeopleCode Events

ItemSelect Event

 The ItemSelected event fires whenever the


end-user selects a menu item from a pop-up
menu.

 In pop-up menus ItemSelected PeopleCode


executes in the context of the page field from
where the pop-up menu is attached, which
means that you can freely reference and change
page fields, just as you could from a pushbutton.

118
PeopleCode Events

ItemSelect

When is it fired?

 The ItemSelected event fires whenever the end-user


selects a menu item from a pop-up menu.

119
PeopleCode Events

ItemSelect

Where is it used?

 In pop-up menus ItemSelected PeopleCode executes in


the context of the page field from where the pop-up
menu is attached, which means that you can freely
reference and change page fields, just as you could from
a pushbutton.

120
PeopleCode Events

ItemSelect

What is it used for?


 ItemSelected PeopleCode is only associated with pop-up
menu items.

121
PeopleCode Events

ItemSelect

Restrictions

 This event, and all it’s associated PeopleCode, does not


fire if run from a Component Interface.

122
ItemSelected Processing

ItemSelected processing occurs when a end-user selects a menu item


from a pop-up menu. This fires the ItemSelected PeopleCode event,
which is a menu PeopleCode event.

123
ItemSelect Event

This code is used to transfer to a new page


by selecting the Menu Item.

124
ItemSelect Event

Popup Menu Icon.

125
ItemSelect Event

Menu Items

126
ItemSelect Event

Transferred to Emppage from Empsal

127
PeopleCode Event – RowInsert Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?
Insert Delete
PostBuild
RowInsert RowDelete

128
PeopleCode Events

RowInsert

When is it fired?
 The RowInsert triggers PeopleCode on any field on the
inserted row of data.

129
PeopleCode Events

RowInsert

Where is it used?
 RowInsert PeopleCode can be associated with record
fields and component records.

 RowInsert PeopleCode is used for processing newly


inserted rows.

130
PeopleCode Events

RowInsert

What is it used for?


 By selecting the “No Row Insert” check box in the
scroll bar’s “page field properties”, the user is
prevented from inserting rows into a scroll area.
 However user cannot be prevented conditionally from
inserting new rows.

131
PeopleCode Events

RowInsert

Restrictions
 Do not put PeopleCode in RowInsert that already exists
in RowInit, because RowInit event always fires after the
RowInsert event, which will cause your code to be run
twice.
 Do not use a warning or Error in RowInsert, this will
cause a runtime error and force cancellation of the
component.

132
RowInsert Event

This code auto generates


the serial number when a
New record is added.

133
RowInsert Event

The function defined in the previous slide is


called here as a function call.

134
RowInsert Event

The serial number is generated

135
PeopleCode Event – RowDelete Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

Insert Delete
PostBuild
RowInsert RowDelete

136
PeopleCode Event

RowDelete Event
 The RowDelete event fires whenever an end-user
attempts to delete a row of data from a page scroll

 The RowDelete event triggers PeopleCode on any


field on the row of data that is being flagged as
deleted

137
PeopleCode Event

RowDelete Event
 When is it fired?

Row Delete processing occurs when:


 The end-user requests a row delete in a scroll by
pressing ALT+F 8 then pressing ENTER, clicking the
Delete Row button, or clicking the Delete button.

 A PeopleCode RowDelete function or a


DeleteRow method requests a row delete.

138
PeopleCode Event

RowDelete Event

Where is it used?

RowDelete PeopleCode is used to prevent the


deletion of a row (using an Error or Warning
statement) or to perform any other processing
contingent on row deletion.

139
PeopleCode Event

RowDelete Event

What is it used for?

When the RowDelete Event get triggered, the


PeopleCode in the event is get executed

RowDelete PeopleCode enables you to check for


conditions and control whether the end-user can
delete the row

140
PeopleCode Event

Restrictions:

RowDelete does not trigger programs on Derived/Work


records

141
PeopleCode Event

RowDelete Event Processing


The Component Processor:
 Fires the RowDelete PeopleCode event, which triggers RowDelete
PeopleCode associated with the record field or the component
record. This event processes fields on the deleted row and any
dependent child scrolls.
 An Error statement displays a message and prevents the
end-user from deleting the row.
 A Warning statement displays a message alerting the
end-user about possible consequences of the deletion, but
permits deletion of the row.

142
PeopleCode Event

RowDelete Event
Logic of row delete processing

143
PeopleCode Event
RowDelete Event
Errors and Warnings in RowDelete
 When you delete a row of data (F 8), the system
prompts you to confirm. If you do confirm, RowDelete
PeopleCode takes place, Errors and warnings in
RowDelete display a message box.

 A warning from RowDelete presents two choices–


accept the RowDelete (the OK pushbutton), or cancel
the RowDelete (the Cancel pushbutton).

 An error from RowDelete PeopleCode prevents the


Component Processor from removing that row of data
from the page.

144
RowDelete Event

The record with employee number 10050 has been stored with the
Serial number 2

145
RowDelete Event

when a record is deleted ,this code automatically


re-numbers the serial number of a remaining
Records in sequence.

146
RowDelete Event

147
RowDelete Event

The delete action will occur when the transaction get saved

148
RowDelete Event

Now the records are renumbered in a sequence

149
PeopleCode Event – SaveEdit Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

150
PeopleCode Event

SaveEdit Event
 The SaveEdit event fires whenever the end-user
attempts to save the component.

 SaveEdit is not field-specific: it triggers associated


PeopleCode on every row of data in the component
buffers, except rows flagged as deleted.

151
PeopleCode Event
SaveEdit Event

When is it fired?
SaveEdit Event gets Fired when
 The user directs the system to save a component
by clicking Save or by pressing ALT+F1, then
ENTER.

 PeopleSoft also prompts the end-user to save a


component when the Next or List button is
selected, or when a new action or component is
selected.

152
PeopleCode Event

SaveEdit Event

Where is it used?
 You can use SaveEdit PeopleCode to validate the
consistency of data in component fields.
 Whenever a validation involves more than one
component field, you should use SaveEdit
PeopleCode.

153
PeopleCode Event

SaveEdit Event
What is it used for?
 When the SaveEdit Event gets fired, the PeopleCode
in the event is get executed .

 This enables you to cross-validate the page fields


before saving, checking consistency among the page
field values.

154
PeopleCode Event

SaveEdit Event Processing


The Component Processor

 Fires the SaveEdit PeopleCode event, which triggers


any SaveEdit PeopleCode associated with a record
field or a component record.
 An Error statement in SaveEdit PeopleCode displays a
message and then redisplays the page, stopping the save.

 A Warning statement enables the end-user to cancel save


processing by clicking Cancel, or continue with save
processing by clicking OK.

155
PeopleCode Event

This code displays an error message when


the user tries to add the record without
entering the employee name.

156
SaveEdit Event

This is how we can add


a record.

157
SaveEdit Event

User is trying to save the record


without entering the employee
name.

158
PeopleCode Event – SavePreChange Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

159
PeopleCode Event

Save Prechange Event

 SavePreChange PeopleCode provides one final


opportunity to manipulate data before the system
updates the database

 SavePreChange PeopleCode can be associated with


record fields, components, and component records.

160
PeopleCode Event

SavePreChange Event

When is it fired?
 The SavePreChange event fires after SaveEdit
completes without errors.

161
PeopleCode Event

SavePreChange Event
Where is it used?
 SavePreChange PeopleCode can be associated
with record fields, components, and
component records.

 SavePreChange PeopleCode is not field-


specific: it triggers PeopleCode on all fields
and on all rows of data in the component
buffer.

162
PeopleCode Event

SavePreChange Event
What is it used for?
 SavePreChange PeopleCode enables you to process
data after validation and before the database is
updated.

163
SavePreChange Event

SQL Commit

164
SavePreChange Event

This code is to capture the details like


who modified the record and when was it modified

165
SavePreChange Event

Push Button to open the


This record has been modified. Secondary page
The required details can be obtained by
Opening the secondary page

166
SavePreChange Event

The details like who


and when the record was modified

167
PeopleCode Event – PostBuild Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

168
PeopleCode Event

Workflow Event

 The main purpose of the Workflow event is to


segregate PeopleCode related to Workflow from the
rest of the application’s PeopleCode

 Workflow PeopleCode executes immediately after


SavePreChange and before the database update that
precedes SavePostChange

169
PeopleCode Event

Workflow Event

When is it fired?
 Workflow PeopleCode executes immediately after
SavePreChange and before the database update
that precedes SavePostChange.
 The program should deal with Workflow only after

any SavePreChange processing is complete.

170
PeopleCode Event

Workflow Event

Where is it used?
 Workflow PeopleCode can be associated with
record fields and components
 Workflow PeopleCode is not field-specific: it

triggers PeopleCode on all fields and on all rows of


data in the component buffer.

171
PeopleCode Event

Workflow event

What is it used for?


 The Workflow event, triggers any Workflow PeopleCode
associated with a record field or a component.

 Workflow PeopleCode should be used only for workflow-


related processing

 Updates the database with the changed component data,


performing any necessary SQL Inserts, Updates, and
Deletes.

172
WorkFlow Event

This code is to trigger the particular event in the activity.


This code is to trigger the particular event in the activity.

173
WorkFlow Event

Adding a New Department

Adding Department Name

Save it.

174
WorkFlow Event

Click on the Worklist tab

175
WorkFlow Event

The added department name has been displayed in the worklist

176
PeopleCode Event – SavePostChange Event
MENU Activate

SearchInit Page Displayed and


Waits for User
Action
SearchSave
Save Action
FieldEdit
RowSelect SaveEdit
FieldChange
PreBuild SavePrechange
YES
Popup Menu
FieldDefault WorkFlow
NO
PrePopup
FieldFormula Other Actions
SavePostChange
ItemSelected

RowInit
Row Actions?

PostBuild Insert Delete


RowInsert RowDelete

177
PeopleCode Event

SavePostChange Event

 After the Component Processor updates the


database, it fires the SavePostChange event

 The system issues a SQL Commit after


SavePostChange PeopleCode completes
successfully.

178
PeopleCode Event

SavePostChange Event
When is it fired?
 The SavePostChange Event is fired after the
Workflow Event is executed successfully.

 SavePostChange PeopleCode is not field-specific:


It triggers PeopleCode on all fields and on all rows
of data in the component buffer

179
PeopleCode Event

SavePostChange Event

Where is it used?

 SavePostChange PeopleCode can be associated


with record fields, components, and component
records.
 SavePostChange PeopleCode is used to update
tables which are not in user component with the
help of SQLExec built-in functions.

180
PeopleCode Event

SavePostChange Event
What is it used for?
 The SavePostChange event, triggers any Workflow
PeopleCode associated with a record field or a
component.

 SavePostChange PeopleCode is for processing that


must occur after the database update, such as updates
to other database tables not in the component buffer.

181
PeopleCode Event

SavePostChange Event

Restriction
 An Error or Warning in SavePostChange PeopleCode
causes a runtime error, forcing the end-user to cancel the
component without saving changes. Avoid Errors and
Warnings in this event.

 Never issue a SQL Commit or a Rollback manually from within


a SQLExec function. Let the Component Processor issue
these SQL commands.

182
SavePostChange Event

To see the value in


the salary field before
the Save Post change
event fires.

183
SavePostChange Event

Note that the


value in
employee salary
is 15000.

184
SavePostChange Event

PeopleCode to update the employee


salary of a particular record.

185
SavePostChange Event

Now note that the


employee salary is
updated to 10000 from
15000.

186

You might also like