PeopleCode

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;

GetUserDescr
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!

Get PeopleSoft Home (PS_HOME) Using PeopleCode

PeopleCode to get PS Home from your server:

&PS_HOME = LTrim(RTrim(GetEnv("PS_HOME"), "/"), "/");

Easy and straight to the point :)

Delete Multiple Files Using PeopleCode

Deleting files sitting on a server using PeopleCode is one thing I'm sure you will be doing sometime during your PeopleSoft career. The code below should help you out and get you started!

Stop Inserting Grid Rows Using PeopleCode

You can do the following to stop inserting grid rows via people code. This should work in a RowInsert event.

&Rowset.InsertEnabled = False;

Auto Increment a Number in PeopleSoft

Use the GetNextNumber function to increment the value in a record for the field you specify by one.

Syntax:
GetNextNumber ({record.field | record_name, field_name}, max_number)

Best place to add such code is in SavePostChange event.

Example:
My_Field = GetNextNumber(My_Record.My_Field, 99999999);

PeopleCode Field Reference Short Cut

When you are developing with PeopleCode, You can refer to any field on any record definition. All fields references MUST be in the buffer while the program is being executed.

If referred to by just field name, PeopleCode assumes you are dealing with the current record.

If coming from another record you must qualify the field with RECORD.FIELDNAME

However, if you are coding your PeopleCode program from within the field you want reference, you can Press the SHIFT+6 keys which gives you the ^ character.

Scheduling a Process in PeopleCode

Here is a great example of how to schedule a process and email the results from within PeopleCode. You can do this within an App Engine Program or even by placing a push button with FieldChange peoplecode.

Local ProcessRequest &RQST;
Local string &Subject;
Local string &Text;