PeopleCode | Automatically set the EMPLID when entering a search record.
A. Standard Functionality?
On certain pages in the system you may notice the EMPLID being carried forward from one component to the next. In other words, the EMPLID you used on component A now appears automatically on the search record of component B. Such a feature might appear to be built-in functionality that works ‘out-of-the-box’, however the search record of the component requires PeopleCode to ensure the defaulting behaviour takes place.
B. Required PeopleCode
To properly implement this functionality, two pieces of PeopleCode must be added to the search record: (1) setting the EMPLID when the user first enters the search record, and (2) if the user selects an EMPLID, making a note of this EMPLID so that it can be carried forward to the next component. In general, (1) is commonly implemented while (2) is only occasionally implemented. However, both pieces of PeopleCode should be included for the functionality to work as designed.
The carry forward functionality uses global variables to keep a track of the EMPLID currently being processed by each user, along with any EMPLID preference stored for the user (field CARRY_ID on record PS_OPR_DEF_TBL_CS). Fortunately, you do not need to know the inner workings of the carry forward functionality. Simply including the code snippets below will take advantage of a delivered PeopleCode function that does most of the work.
Firstly, to set the EMPLID when entering the search record, place the following code on the ‘SearchInit’ event on the EMPLID field of your search record.
Declare Function check_carry PeopleCode FUNCLIB_CS.CARRY_ID FieldFormula; If %Mode <> "A" Then check_carry(&EMPLID); If All(&EMPLID) Then RECORD_NAME.EMPLID = &EMPLID; End-If; Else SetDefault(RECORD_NAME.EMPLID); End-If;
Make sure to replace ‘RECORD_NAME’ with your own record.
Secondly, to keep a track of any EMPLID entered by the user, place the following code on the ‘RowInit’ event of the EMPLID field:
Global string &EMPLID_CARRY; Global string &CARRY_ID; /* Save Emplid into EMPLID_CARRY */ If &CARRY_ID = "Y" Then &EMPLID_CARRY = RECORD_NAME.EMPLID; End-If;
C. Other Uses
Although we have only spoken about EMPLID as part of this tip (a key field in PeopleSoft HR and Campus Solutions), similar carry-forward functionality could be created for any other commonly accessed field in the system.