• Understanding Peoplecode – FieldChange, FieldEdit, FieldDefault, FieldFormula Events

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

    FieldChange

    The FieldChange event is triggered when is field is changed. Use FieldChange PeopleCode to recalculate page field values, change the appearance of page controls, or perform other processing that results from a field change other than data validation. To validate the contents of the field, use the FieldEdit event.

    Code Example in FieldChange

    If %Page = Page.PAGE_NAME Then
          RECORD_WRK.CALC_FIELD = RECORD1.FIELD1 * RECORD2.FIELD2;
    End-If;
    

    Important things to Note

    • Used to perform additional processing that is based on the new value of changed field.
    • FieldChange PeopleCode can be associated with record fields and component record fields.
    • FieldChange and RowInit peoplecode are often paired together.
    • Donot use this event for validations, use FieldEdit instead.

    FieldEdit

    Use FieldEdit PeopleCode to validate the contents of a field, supplementing standard system edits. If the data does not pass the validation, the PeopleCode program should display a message using the Error statement, which redisplays the page, displaying an error message and turning the field red.

    Important things to Note

    • Performs after the field value has been changed and the new value of the field satisfies the standard system edits (Eg. Prompt Table Edit).
    • Used to validate Content of the field.
    • Only fires on specific field or row that has has Changed.
    • Associated with Record Fields and Component Record Fields.

    FieldDefault

    The FieldDefault PeopleCode event enables you to programmatically set fields to default values when they are initially displayed.

    Important things to Note

    • Used to populate default values to fields generally in Add Mode.
    • We can set FieldDefault through Record Field Properties too, but it would be static value. In case we want to change the Default value based on some condition we can use the event.
    • Record Field Properties overrides this event.
    • This Performs only if the field it is being attached to has no value.
    • Associated with Record Fields and Component Record Fields.
    • If a field value is changed, whether through PeopleCode or by a user, the IsChanged property for the row is set to True. The exception to this is when a change is done in the FieldDefault or FieldFormula events. If a value is set in FieldDefault or FieldFormula, the row is not marked as changed.

    FieldFormula

    FieldFormula is mainly used to record definitions to store shared functions. It can be used for other functionality too but RowInit and FieldChange are preferred methods.

    • The FieldFormula event is not currently used (for setting values, hiding fields etc). Because FieldFormula PeopleCode initiates in many different contexts and triggers PeopleCode on every field on every row in the component buffer, it can seriously degrade application performance.
    • As a matter of convention, FieldFormula is now often used in FUNCLIB_ (function library) record definitions to store shared functions. However, you can store shared functions in any PeopleCode event.
    • FieldFormula PeopleCode is only associated with record fields.
    • If a field value is changed, whether through PeopleCode or by a user, the IsChanged property for the row is set to True. The exception to this is when a change is done in the FieldDefault or FieldFormula events. If a value is set in FieldDefault or FieldFormula, the row is not marked as changed.
    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