Blogs

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;
Else
GetRowset().InsertEnabled = False;
End-If;

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 ***/

Display Only the Last 4 Digits of a Social Security Number

The PeopleCode below will only display the last 4 digits of a social security number. I have placed the code in a Component PostBuild event and it works perfect.

DERIVED_HR.SOCIAL_SECURITY_NUMBER = Replace(DERIVED_HR.SOCIAL_SECURITY_NUMBER, 1, 7, “XXX-XX-);

Here, I’m using the replace PeopleCode built-in function. The functions takes the value from a the above field, starts at position 1 and replaces the 1st 7 characters with the string “xxx-xx-”.
The result:
After this code gets executed, SSN on a page should show up as xxx-xx-5623

Delete a File Using PeopleCode

It is always a good idea to check for a file if exists before trying to delete it. So the code below will check for that and then will attempt to delete the file if found. The delete is performed using the build-in peoplecode function DeleteAttachment.
The code below also checks for the returned code by the function to verify whether the file has been deleted or not.
&retcode = DeleteAttachment(URL.BKFTP, ATTACHSYSFILENAME);
If (&retcode = %Attachment_Success) Then
MessageBox(0, “File Attachment Status”, 0, 0, “DeleteAttachment succeeded”);
UnHide(ATTACHADD);

Hide a Group Box on a Page Using PeopleCode

To hide a group box and all the fields placed in it on a PeopleSoft page use the code below in a page “Activate” event.

HR_LBL_WRK.STATUS_LBL.Visible = False;

Where HR_LBL_WRK is the record name, and STATUS_LBL is the field record. Double click on the Group Box to see its record properties (1st tab).
For the Group box and all the fields in it to be completely hidden, make sure the “Hide Border” and “Adjust Layout for Hidden Fields” on the Label tab are checked and the “Hide all Fields when Group Box Hidden” on the Use tab is also checked.

Check Email Address and Type on a PeopleSoft Grid

The grid looks like this:

PeopleCode to restrict Xlat Values

What I would like to accomplish is every time the user adds a new email address i would want to check for the following:
1. Check for blank email type
2. Edit to check for '@' character
3. Check if email address is blank
4. Check for duplicate email type in the same grid

Using Hyperlinks in Queries to Drill Down to Individual Values

I came across a PeopleSoft posting written by Rob's PeopleSoft Blog and could not help but to post it on my blog. It is a neat trick and I'm sure will come handy in many occasions!

Download Oracle OpenWorld 2007 Session Presentations

Every year, Oracle makes the Openworld session presentations available for public in a PDF format. Click here to take a look at what is available for you to download.

SQL to Check PeopleSoft Process Name Status

Run this SQL on a particulare process name to get it's process status form PeopleSoft process request.

SELECT a.prcsname, a.oprid, a.servernamerun, b.xlatlongname AS STATUS,
a.rundttm,
TRUNC (MOD ((a.enddttm - a.rundttm) * 24, 24)) "Hr",
TRUNC (MOD ((a.enddttm - a.rundttm) * 24 * 60, 60)) mi,
TRUNC (MOD ((a.enddttm - a.rundttm) * 24 * 60 * 60, 60)) sec,
a.prcsinstance, c.outputdir
FROM psprcsrqst a, xlattable b, ps_cdm_list c
WHERE b.fieldname = 'RUNSTATUS'
AND b.fieldvalue = a.runstatus
AND a.prcsinstance = c.prcsinstance
AND a.prcsname = 'YourProcessName'

Adding a Sub Record Field into a Grid or Scroll Area

I kept getting this weird PeopleSoft error when trying to drop a sub record field into a Grid or Scroll area on a page. The error was this:

Fields from subrecords are not allowed to be inserted directly into the page. Use Subpage instead.

What? You have to be kidding me! I know this could be done and I don’t need a subpage for this. I’ve seen it done and I’ve actually got it done! This is what I did.