PeopleCode Bypass Search Page by Role

Sometimes you would like to bypass the search page depending on the
user's role. For some users, they need the ability to look at other
employee’s time sheets, managers for example. However, for others, they
should only be restricted to their own data. Below is PeopleCode
example that will bypass the search page depending on users' role.

Read Data From Table or Views into a Rowset Object

Grids are used all the time in PeopleSoft, and to populate them with
dynamic data could be quite challenging. Use the "Select" function to
read data from the database tables or views into either a row or rowset

The following example first flushes the hidden work
scroll, then selects into it based on a field on the page, or any
criteria that you add to the “where clause”.

FetchValue & UpdateValue PoepleCode Functions

In order to reference the value of a field within a looping statement, the FetchValue and UpdateValue build-in functions can be used.

  • FetchValue(SCROLL.record_name, target_row, [recordname.]fieldname)
  • UpdateValue(SCROLL.record_name, target_row, [recordname.]fieldname), value)


Porcessing Rows Using Loops (ActiveRowCount)

In order to loop through the rows on an occurs level you need to
know the number of rows. ActiveRowCount returns the number of active
rows in a scroll.

For &I = 1 To ActiveRowCount(Scroll.PSU_STU_ENROLL)
/*your statement goes here*/

Difference Between MsgGet, MessageBox, & MsgGetText PeopleCode Functions

Wondering why there are 3 different functions or ways to get text
from a message catalog? Check the comparison below and decide which one
best fits your needs.

MsgGet(message_set, message_num, default_msg_txt [, paramlist])
The MsgGet function
retrieves a message from the PeopleCode Message Catalog and substitutes
in the values of the parameters into the text message.
Example: &MsgText = MsgGet(30000, 2, "Message not found");

Arrays in PeopleSoft

Few examples to help clarify how PeopleSoft arrays work.

Local Array of Number &MYARRAY;
&MYARRAY = CreateArray(100, 200, 300); Result is [100] [200] [300]

You can assign values to the elements of the array:

Local Array of Number &MYARRAY;
&MYARRAY = CreateArrayRept(0,3); Result is [0] [0] [0]
&MYARRAY[1] = 100; Result is [100] [0] [0]
&MYARRAY[1] = 200; Result is [100] [200] [0]
&MYARRAY[1] = 300; Result is [100] [200] [300]

How to Declare a Function in PeopleCode

Declaring a function using PeopleCode is pretty straight forward and this is how you can do that:

Declare Function GetUserDescr PeopleCode FUNCLIB_PTSEC.OPRID FieldFormula;

is the function name you want to declare. FUNCLIB_PTSEC is the record where the function has been stored, and OPRID is the field the function is under, and finally FieldFormula is where the function is located within the “OPRID” field.

Hope this was helpful!

PeopleSoft Component PreBuild Event

Things to know about Component PreBuild Event PeopleCode:

  • PreBuild executes only once during the component build process.
  • PreBuild is often used to hide or unhide pages.
  • It can be used to set global or component scope variables.
  • PreBuild can only be placed on the component.
  • Do not place errors or warnings in PreBuild.

The code below populates the OPRDEFNDESC field if it is empty:

Declare Function GetUserDescr PeopleCode FUNCLIB_PTSEC.OPRID FieldFormula;

PeopleCode SearchSave Event

SearchSave PeopleCode is performed after the user clicks the Search button or the Add button on the search page.

  • User SearchSave to validate values entered in the search page fields.
  • Place SearchSave PeopleCode on search key fields or alternate search key fields on a search record or component search record.
  • User Error and Warning statement to validate search page fields.

Here is an example of a SearchSave PeopleCode event:

PeopleCode SearchInit Event

Things to know about SearchInit PeopleCode event:

  • SearchInit PeopleCode is performed before the search page is displayed.
  • User SearchInit to control processing before a user enters values in the search page.
  • Place SearchInit PeopleCode on search key fields or alternate search key fields on a search record or component search record.
  • Do not place errors or warnings in SearchInit

Here is an example that prevents a user from using the change password page to change another user's password!