Lepa's blog

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.

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

Best place to add such code is in SavePostChange event.

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;

Display Text Catalog on a PeopleSoft Page

A new functionality in PeopleSoft is the ability to use Text Catalog instead of Message Catalog and display the text on the page. Some main advantages, as I’ve noticed, by using Text Catalog is the ability to use HTML and make text effective dated.

So, lets get right into it and see how is this done!

Navigate to Set Up HRMS > Common Definitions > Text Catalog and Notepad > Maintain Text Catalog then go ahead and create your text catalog that we will be using.

%Concat Meta-SQL in PeopleCode

%Concat resolves to the database-specific concatenation operator so you don't have to guess which way it is done.

The following PeopleCode uses the %Concat meta-sql meta-variable:


On SQL Server, this code resolves to:

Defining PeopleCode Events

Every PeopleCode program is associated with a PeopleSoft Application Designer definition and with an event. Events are predefined exit points in the component processor flow. As each point is encountered, the event runs PeopleCode for that event each definition.

The below is an attempt to map the 17 Component Processor PeopleCode events to the Component Process Flow:

Search Action Events:
SearchInit, SearchSave

Add to Date using PeopleCode

I came across the below PeopleCode built-in function when trying to find a way to add a month to %date. So, here it is as PeopleSoft explaines it.
My code ended up being like this :

/*Adding one month to system date*/
AddToDate(%date, 0,1,0);

AddToDate(date, num_years, num_months, num_days)
Use the AddToDate function to add the specified number of years, months, and days to the date provided.

Stop or Prevent Inserting Grid Rows Via PeopleCode

The PeoleCode below will prevent users from inserting more than 2 rows on a grid. The "+" button will disappear the moment a 2nd row is added by a user. I have place this code on a record field under rowinit event.
If GetRowset().ActiveRowCount = 1 Then
GetRowset().InsertEnabled = True;
GetRowset().InsertEnabled = False;

FTP a File Using PeopleCode

Here is a function to FTP a file on a server using PeopleCode.
Local string &FtpUserID;
Local string &FtpPassword;
Local string &FtpURL;
Function ftp_file;
&FtpUserID = “user_id”;
&FtpPassword = “password”;
&FtpURL = “directory_name/subdirectory_name”;
&targetFile = “File_Name”;
/* Set ftp string */
&Ftp_my_file = “ftp://” | &FtpUserID | “:” | &FtpPassword | “@” | &FtpURL;
/*** It is always a good practice to check to see if local file exists before trying to transfer it ***/