Tuesday, October 22, 2013

Get the last day of the month with PeopleCode!

One nice thing to write the function to get "the last day of the month" in PeopleCode is that there is no restriction with the database platform.

Here is the easy how to:

   Local integer &year = Year(%Date);
   Local integer &month = Month(%Date);
   
   /* Get the last day of the month */
   If &month < 12 Then
      &last_day = Date3(&year, &month + 1, 1) - 1;
   Else
      &last_day = Date3(&year + 1, 1, 1) - 1;
   End-If;

Wednesday, October 2, 2013

Ez way to mask value in peoplecode

You can use this one line of code to mask sensitive data such as social security, bank account, etc.

Local string &_value = "123456789"; 
Local string &_masking_char = "*"; /* masking character */
Local integer &_digit_display = 4; /* number to display */
Local string &_new_value;

&_new_value = Rept(&_masking_char, Len(&_value) - &_digit_display) | Substring(&_value, (Len(&_value) - &_digit_display) + 1, Len(&_value));

Result:
&_new_value is *****6789


Get the First & Last Day of The Month In Oracle

Oracle figures if we can get the last day of the month using its handy LAST_DAY function, we should be able to figure out the first day, right?

Yep, here is one of many ways to get the first and last day of the month in Oracle.

Select  (last_day(:1)  - TO_CHAR(last_day(:1), 'DD')) + 1 as First_Day, last_day(:1) as last_Day from dual

Replace bind :1 to the actual date, then you get the result below:


Friday, July 5, 2013

Boring or Not So Boring Page, You Decide!



I decided in one of my recent developments to use jQuery in Peoplesoft FAQ page for a sleeker and smoother GUI interaction rather than a boring standard peoplesoft page (you know what I meant ;).  I mainly used the accordion for the FAQs and auto complete for the keyword search.  There are at least more than one way to reference the jQuery library from your peoplesoft page, but I found using the HTML definition is quite simple and easy.

This is what the end result looks like:

  • Auto complete function will search all possible FAQs from the search box
  • The FAQ's answer will be revealed when the FAQ is clicked and the box will smoothly expand/collapse

Here is what I did...
  1. Go to jquery.com and download the jQuery v.1.9.1 and jQuery UI v1.10.3 (pick the version that applied to you)
  2. Open a new HTML definition and copy/paste the jQuery code into it and I saved it as Y_JQUERY (name whatever you desire)

  3. Open a new HTML definition and copy/paste the jQuery UI code into it and I saved it as Y_JQUERY_UI (name whatever you desire)

  4. Open a new HTML definition and write a jQuery script (find a lot of code samples in jquery website) and I saved it as Y_ACCORDION_JQUERY (name whatever you desire).

    Several things to note are the bind variables that I use as input parameters:
    • %Bind(:1) = FAQ data
    • %Bind(:2) = url reference to jQuery library
    • %Bind(:3) = url reference to jQuery UI library
    • %Bind(:4) = array of keyword for auto complete search

     
  5. Open a new HTML definition and write a javascript to build the url with appropriate query strings, such as Y_FAQ_ID to determine what FAQ to display from the FAQ setup (not included in this tutorial), RETURN_LNK to determine to return link (not included in this tutorial), and TAGS (the field name from the edit box#2 to get the keyword for the search)


     
  6. Create a page definition.  Add HTML #1 (FAQs page w/ jQuery Accordion Style), edit box field (search box), and HTML#3 (search button for auto complete)


    • HTML area #1
    •  Name the page field "TAGS" to the edit box #2
    • HTML area #3
  7. Finally, write the page peoplecode to put pieces together and let the magic happens here!



    That should be it!  Not too bad, huh!

Thursday, January 10, 2013

Disable Peoplesoft radio button using javascript

In my recent development, I need to disable one of three radio buttons based on a condition. The dilemma here is that a radio button is using the same field, so using field property displayonly = True or enabled = False won't work in this sense.

 How do I do this:
 

To something like this (note: catch up below is grayed out):



Here is a step by step work around to disable one radio button using a simple javascript.
  1. We need to set a page field name from the radio button properties.  I named this one "ADJ_CATCHUP".

  2. Place HTML area to the bottom of the page to make sure that the page had been fully rendered before the javascript being called)

  3. Assign Record and Field into the HTML area properties


  4. Create a new HTML definition
    Note: (I use bind variable so I can reuse this HTML code with a different field name or property(true/false)


  5. Place the peoplecode below where you need it.  In my case, I put it in the page activate.
    If &_has_paid_amounts  is True, then it will disable catch up radio button.  Otherwise, enable it.


  6. That should be it.