# Create a Follow-Up Task When Opportunity Stage Changes

**Type:** Apex trigger · **Difficulty:** Hard · **Object:** Opportunity · **Topics:** Opportunity, Task, After Update, Trigger.oldMap, Bulkification

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/create-follow-up-task-when-opportunity-stage-changes

## Problem

When an Opportunity changes stage, create a follow-up task linked to it. Include the new stage in the task description. Do not create a task when the stage did not change. Handle the whole batch in one DML operation.

## Constraints

Use bulk-safe logic. Do not run SOQL or DML inside loops.

---
Source: ForceChallenges · last updated 2026-10-13
