18 Grouping Logic and Background Execution
Group related page processes in an execution chain and offload longer-running tasks to the background.
Use an Execution Chain page process to group a sequence of child processes. Its server-side condition determines whether the children execute. They can be any kind of page process to execute code, invoke APIs and REST services, start workflows, print reports, send emails or push notification, load data, and more. Since chains can nest within chains, your logic becomes a self-documenting outline when you use clear, descriptive names.
Execution chains also improve user experience. Offload long-running work by adding child processes to a chain and enabling its Run in Background switch. The APEX runs the work in the background moves on to the next page process in the user session. Background jobs run in a distinct session, with a private copy of the page's session state. Do anything you need to, including processing user-uploaded files, reporting progress, and notifying users when complete.
You can limit background jobs per user and declaratively serialize them to avoid resource contention or to prevent multiple executions for the same context value. Workspace administrators set overall limits and can grant background jobs more resources when needed.
- Exploring Employee Excellence for HR Reps
Preview the Employee Excellence page, where HR reps send welcome packets and start background award reviews. - Outlining Logic Using Execution Chains
Organize page processing logic into a clear outline using nested execution chains. - Offloading Work to the Background
Offload longer-running page processing to the background so users can keep working. - Serializing Background Process Jobs
Serialize background jobs by type or context value to prevent conflicting work. - Understanding Cloned Session State
Understand how background jobs use an isolated copy of the user’s session state. - Reporting Background Progress
Show users background job progress with theAPEX_APPL_PAGE_BG_PROC_STATUSview. - Loading Data in the Background
Load uploaded data in the background and notify users when processing completes. - Limiting and Throttling Background Jobs
Limit or throttle background execution chain jobs at the chain, application, or workspace level. - Adjusting Resources for Background Jobs
Configure a custom job class when background process jobs need different resource limits. - Debugging Background Processes
Debug background execution chains by viewing jobs, session state, and failure details.