ForceChallenges
ProblemsDailyNotes
Sign in
Problem list
Sign in to submit

Sync Opportunity Client Contact to Its Account

HardApex Triggeron Opportunity 50 ptsCreated Oct 13, 2026

An Opportunity and its Account both have a Client_Contact__c field. When the Opportunity's client contact changes, copy the new contact to the related Account. Do not update Accounts when the Opportunity has no Account. Handle multiple Opportunities in one batch.

Constraints

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

OpportunityAccountCross Object UpdateTrigger.oldMapBulkification
CodeApex
Loading editor…
Opportunity contact updates account contact

Seed data

Account× 1 rows
Name: Client Account
Contact× 1 rows
LastName: Client Person
Opportunity× 1 rows
Name: Client DealAccountId: {{id:Account:1}}CloseDate: 2027-01-01StageName: Prospecting

DML under test

updateOpportunityWHERE Name = 'Client Deal'
SET
Client_Contact__c: {{id:Contact:1}}

Expected

  • SELECT COUNT() FROM Account WHERE Client_Contact__c != null