• Understanding Peoplecode – Search Init Event

    Posted on September 23, 2012 by in Other Programming, People Soft

    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


    Important things to Note

    • SearchInit PeopleCode is performed before the search page appears.
    • Place SearchInit PeopleCode on search key fields or alternate search key fields on a search record or component search record.
    • Do not place errors or warnings in SearchInit.
    • SearchInit PeopleCode can be associated with record fields and component searchrecords.
    • You cannot use DoModal,DoModalComponent,Transfer,TransferPage within SearchInit

    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:

    • All required keys have been provided (either by system defaults or by PeopleCode).
    • If this an Add dialog box, then no duplicate key error results from the provided keys; if this error occurs, the processing resets to the default behavior.
    • If this is a Search dialog box, then at least one row is returned based on the provided keys.

    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.

    Other Important Functions

    Some of the other commonly used functions in search init are SetSearchEdit, ClearSearchEdit, IsSearchDialog, ClearSearchDefault.

    SearchSave Event

    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.");
    Error MsgGet(48, 235, "Message not found.");

    Important things to Note

    • SearchSave PeopleCode is performed after the user clicks the Search button or the Add button on the search page.
    • Place SearchSave PeopleCode on search key fields or alternate search key fields on a search record or component search record.
    • Use SearchSave to validate values entered in the search page fields.
    Be Sociable, Share!
      Post Tagged with ,

    Written by

    Vanamali Juvvadi is a Web enthusiast and loves all things design and technology. Founded qnownow with a group of friends to share anything/everything they know/find on the internet.

    View all articles by

    Email : [email protected]

    Leave a Reply