# Prevent Duplicate Opportunity Names per Account

**Type:** Apex trigger · **Difficulty:** Medium · **Object:** Opportunity · **Topics:** Opportunity, Duplicate Check, Bulkification

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/prevent-duplicate-opportunity-names-per-account

## Problem

Do not allow two Opportunities for the same Account to have the same name. The same Opportunity name can be used for a different Account. Check existing records and records in the incoming batch.

## Constraints

Write bulk-safe trigger logic. Do not run SOQL or DML inside a loop.

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