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.
How save processing works
Section titled “How save processing works”When a user saves, the Component Processor runs these steps in order:
- SaveEdit validates the data. An error here stops the save.
- SavePreChange makes last changes before the database is updated. It can still stop the save.
- Workflow runs workflow processing.
- The database update, in which the Component Processor inserts, updates, and deletes rows.
- SavePostChange does work that needs the saved data. It can’t stop the save, because the data is already in the database.
- 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.
Which PeopleCode runs when a user saves the ZZ_TRAINING_REQcomponent, and in what order? Explain what each program does, andfollow any application classes it calls.What happens
Section titled “What happens”-
describe_componentwith{"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"}] -
get_peoplecodereads each of the four programs, using thepathfrom 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(); -
get_peoplecodereads the class, with{"kind": "app_class", "path": "ZZ_TRAINING:Approval:Router"}. -
search_codelooks forZZ_TRAINING:Approval:Routerto find anything else that uses the class, which matters if you plan to change it.
What you get
Section titled “What you get”Save processing for ZZ_TRAINING_REQ (GBL)
- SaveEdit:
ZZ_TRAIN_REQ.REQUEST_DT.SaveEditrejects a request date in the past with an error, which stops the save.- SavePreChange:
ZZ_TRAIN_REQ.ZZ_TRAIN_STATUS.SavePreChangesets the status of a new request to P (Pending Approval).- SavePreChange:
ZZ_TRAINING_REQ.GBL.SavePreChangecounts the employee’s pending requests withSQLExec, and stops the save with an error if there are already three.- Workflow: no programs.
- Database update: the Component Processor saves the changed rows.
- SavePostChange:
ZZ_TRAINING_REQ.GBL.SavePostChangecreates aZZ_TRAINING:Approval:Routerobject, 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.
Check the answer
Section titled “Check the answer”- 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.
Go further
Section titled “Go further”- “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.
