Skip to content

Trace a component's save processing

When a save fails with an unexpected error, or a field changes on save and nobody knows why, you need the whole picture: every PeopleCode program that runs, in order, and what each one does. Putting it together by hand means opening the component, each of its records, and every program in Application Designer. With AI Assist, you ask once.

You’ll use: describe_component, get_peoplecode, and search_code.

When a user saves, the Component Processor runs these steps in order:

  1. SaveEdit validates the data. An error here stops the save.
  2. SavePreChange makes last changes before the database is updated. It can still stop the save.
  3. Workflow runs workflow processing.
  4. The database update, in which the Component Processor inserts, updates, and deletes rows.
  5. SavePostChange does work that needs the saved data. It can’t stop the save, because the data is already in the database.
  6. The commit.

Within each event, record field PeopleCode runs first, followed by PeopleCode defined in the component. The LLM uses this order to explain the programs it finds.

Prompt
Which PeopleCode runs when a user saves the ZZ_TRAINING_REQ
component, and in what order? Explain what each program does, and
follow any application classes it calls.
  1. describe_component with {"component": "ZZ_TRAINING_REQ"} returns the component’s pages, records, and PeopleCode, grouped by event. Four programs run during save:

    Save events in the result
    [
    {
    "event": "SaveEdit",
    "level": "record field",
    "path": "ZZ_TRAIN_REQ.REQUEST_DT.SaveEdit"
    },
    {
    "event": "SavePreChange",
    "level": "record field",
    "path": "ZZ_TRAIN_REQ.ZZ_TRAIN_STATUS.SavePreChange"
    },
    {
    "event": "SavePreChange",
    "level": "component",
    "path": "ZZ_TRAINING_REQ.GBL.SavePreChange"
    },
    {
    "event": "SavePostChange",
    "level": "component",
    "path": "ZZ_TRAINING_REQ.GBL.SavePostChange"
    }
    ]
  2. get_peoplecode reads each of the four programs, using the path from the result. The SavePostChange program imports an application class:

    ZZ_TRAINING_REQ.GBL.SavePostChange (first lines)
    import ZZ_TRAINING:Approval:Router;
    Local ZZ_TRAINING:Approval:Router &router;
    &router = create ZZ_TRAINING:Approval:Router();
  3. get_peoplecode reads the class, with {"kind": "app_class", "path": "ZZ_TRAINING:Approval:Router"}.

  4. search_code looks for ZZ_TRAINING:Approval:Router to find anything else that uses the class, which matters if you plan to change it.

Save processing for ZZ_TRAINING_REQ (GBL)

  1. SaveEdit: ZZ_TRAIN_REQ.REQUEST_DT.SaveEdit rejects a request date in the past with an error, which stops the save.
  2. SavePreChange: ZZ_TRAIN_REQ.ZZ_TRAIN_STATUS.SavePreChange sets the status of a new request to P (Pending Approval).
  3. SavePreChange: ZZ_TRAINING_REQ.GBL.SavePreChange counts the employee’s pending requests with SQLExec, and stops the save with an error if there are already three.
  4. Workflow: no programs.
  5. Database update: the Component Processor saves the changed rows.
  6. SavePostChange: ZZ_TRAINING_REQ.GBL.SavePostChange creates a ZZ_TRAINING:Approval:Router object, which routes a new request to the employee’s manager for approval. It runs after the data is saved, so a failure here can’t undo the save.

Nothing else uses ZZ_TRAINING:Approval:Router, so changes to the class affect only this component.

  • Open the programs. Every path in the answer is a program you can open in Application Designer. Record field programs are on the record, and component programs are on the component.
  • Trace a real save. In a test environment, turn on PeopleCode tracing for your session at PeopleTools > Utilities > Debug > Trace PeopleCode, save a test request, and compare the programs in the trace with the list.
  • “Which of these programs check %Mode, and what do they do differently in Correction mode?”
  • “What happens to the approval routing if the SavePostChange program fails?”
  • “Change the SaveEdit check so it also rejects dates more than a year ahead.” The LLM drafts the code; you review it and apply it in Application Designer.