# Set Lead Rating from Lead Source

**Type:** Apex trigger · **Difficulty:** Easy · **Object:** Lead · **Topics:** Lead, Before Insert, Field Assignment

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/set-lead-rating-from-lead-source

## Problem

When a Lead is created, set Rating to Hot for Web leads, Warm for Phone Inquiry leads, and Cold for other sources. If the user already supplied a Rating, keep it.

## Constraints

Process every record in the batch and handle blank values safely.

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