# Require Competitor for Closed Lost Deals

**Type:** Apex trigger · **Difficulty:** Medium · **Object:** Opportunity · **Topics:** Opportunity, Custom Field, Before Update

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/require-competitor-closed-lost-deals

## Problem

When an Opportunity is changed to Closed Lost, require the custom Competitor__c field to be filled in. Other stages do not need a competitor. Add Competitor__c to the challenge schema.

## Constraints

Keep the trigger bulk-safe. Do not run SOQL or DML inside loops.

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