Sales operations wants an audit of Account rating changes. In a real org this logic lives in an after-update trigger, where Trigger.oldMap and Trigger.newMap give you the before and after state of every changed record, keyed by Id. This challenge simulates that exact pattern, and it is the canonical trigger change-detection technique tested on the PD1 exam under Logic and Process Automation.

Given oldMap and newMap, two maps of Account Id to Account, return the Ids of every Account whose Rating value differs between the two maps. Compare only the Ids present in newMap; if an Id from newMap is missing from oldMap, skip it. A change from null to a value, or from a value to null, still counts as a change. If either map is null or empty, return an empty list. Sort the returned Ids in ascending order before returning them.

Examples:

Input: oldMap = {id1: Account(Rating='Hot')}, newMap = {id1: Account(Rating='Cold')} Output: [id1] Explanation: The Rating value changed from Hot to Cold Input: oldMap = {id1: Account(Rating='Warm'), id2: Account(Rating='Cold')}, newMap = {id1: Account(Rating='Warm'), id2: Account(Rating='Cold')} Output: [] Explanation: No Rating values differ between the two maps Input: oldMap = {id1: Account(Rating=null)}, newMap = {id1: Account(Rating='Warm')} Output: [id1] Explanation: A change from null to a value still counts as a rating change
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay September 2026 (Sep 16–30)Sponsored by FLXBL

Contest runs September 16 - 30. Complete challenges to climb the leaderboard!

Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes

Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In