PeopleCode is an (ool) object-oriented proprietary (case-insensitive) language used to express business logic for PeopleSoft applications. In its fundamentals, PeopleCode...
The SearchInit event is generated just before a search, add, or data-entry dialog box is displayed. SearchInit triggers associated PeopleCode in the search key fields of the search record. This allows you programmatically set values of search daialog fields. For example, if you want allow entry of search field for a user and display default values for other users you could write the below
IF (%OPRID =="USERNAME_REQ") THEN RECORDNAME.SEARCHKEY = ""; ELSE RECORDNAME.SEARCHKEY = "SOMEVALUE"; GRAY(RECORDNAME.SEARCHKEY); END-IF;
Given below are important functions that are used in SearchInit
If you want the SETID to default from the operator defaults table for SETID search field. Add the following PeopleCode to either the Record.Field.SearchInit or Component.Record.SearchInit PeopleCode.
Where RECORD.FIELD refers to the name of the record and field that you set the field default for in the first step.
Use the SetSearchDialogBehavior function in SearchInit PeopleCode to set the behavior of search and add dialog boxes before a page is displayed, overriding the default behavior. There are two dialog behavior settings: skip if possible (0) and force display (1).
Skip if possible means that the dialog box is skipped if all of the following are true:
Force display means that the dialog box displays even if all required keys have been provided. The default behavior of the search and add dialog boxes is force display.
%Mode returns a String value consisting of an uppercase character specifying the action a user selected when starting the current component. The following values can be returned. You can check either for the string value (“A”, “U”, and so on.) or for the constant. It is generally used to check whether the user is in Add Mode or Update/Display Mode.
%Mode is often used in Page Activate, SearchInit, but can be used in other peoplecode events too.
Some of the other commonly used functions in search init are SetSearchEdit, ClearSearchEdit, IsSearchDialog, ClearSearchDefault.
SearchSave event happens when we click on search button of search page after entering the search values. We can write validations to check whether any search criteria is entered on the search page on SearchSave event. In SearchSave event itself search values appear listed in a grid on search page. If any error is issued on this event using peoplecode processing stops and no search result are listed on the page.
Here is an example of a SearchSave PeopleCode event:
rem No spaces allowed in User Id rem also do not allow the userid of PPLSOFT if %Mode = "A" Then &find = Find(" ", PSOPRDEFN_SRCH.OPRID); if &find > 0 Then Error MsgGet(48, 54, "Message not found."); End-If; if Upper(PSOPRDEFN_SRCH.OPRID = "PPLSOFT" Then Error MsgGet(48, 235, "Message not found."); End-If; End-If;