• Understanding Peoplecode – SaveEdit, SavePreChange, SavePostChange Events

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

    SaveEdit

    The SaveEdit event is intiated whenever a user attempts to save the component. You can use SaveEdit PeopleCode to validate the consistency of data in component fields. Whenever a validation involves more than one component field, you should use SaveEdit PeopleCode.

    Important things to Note

    • The component processor applies SaveEdit peoplecode to all non-deleted rows of data in the buffers & all pages in component
    • SaveEdit is better suited than FieldEdit if the validation refrences more than one field or row of data.
    • An Error statement in SaveEdit PeopleCode displays a message and redisplays the component without saving data. A Warning statement enables the user to click OK and save the data, or to click Cancel and return to the component without saving.
    • Use the SetCursorPos function to set the cursor position to a specific page field following a warning or error in SaveEdit, to show the user the field (or at least one of the fields) that is causing the problem. Make sure to call SetCursorPos before the error or warning, because these may terminate the PeopleCode program.
    • Associated with record fields and Components.

    When an error message is issued in PeopleSoft(Component Processor) from the SAVEEDIT event, the cursor will not be directed to the corresponding field (value) for which the message is thrown. And the field also doesnot turn into red color as is the behaviour with the error messages issued from the FIELDEDIT event. Use SetCursorPos as shown above to set the cursor position. Here is example below written in SAVEEDIT.

      IF NONE(RECORD1.FIELD1) THEN
        RECORD1.FIELD1.Setcursorpos(%Page);
        REM To Display field in Red Color
        RECORD1.FIELD1.Style = "PSERROR";
        Error ("The Field is Required");  
      END-IF;
    

    SavePreChange

    The SavePreChange event is initiated after SaveEdit completes without errors.

    Important things to Note

    • SavePreChange PeopleCode provides one final opportunity to manipulate data before the system updates the database; for instance, you could use SavePreChange PeopleCode to set sequential high-level keys
    • If SavePreChange runs successfully, a Workflow event is generated, and then the Component Processor issues appropriate Insert, Update, or Delete SQL statements.
    • An Error statement in SaveEdit PeopleCode displays a message and redisplays the component without saving data. A Warning statement enables the user to click OK and save the data, or to click Cancel and return to the component without saving.
    • Used to change display characteristics and validations
    • SavePreChange PeopleCode can be associated with record fields, components, and component records.

    SavePostChange

    After the Component Processor updates the database, it initiates the SavePostChange event. You can use SavePostChange PeopleCode to update tables not in your component using the SQLExec built-in function.

    • Performs after SavePreChange and Workflow have completed successfully. SavePostChange is not executed if workflow fails or component is not saved due to any error.
    • Donot use Error and Warnings in this event
    • The system issues a SQL Commit statement after SavePostChange PeopleCode completes successfully.
    • Other than updating tables that are not in your component, it is also used to send an email , say for approval.
    • SavePostChange PeopleCode can be associated with record fields, components, and component records.
    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