Question: Salesforce Trailhead – Trigger Not Passing Challenge (FREE Bouquet Issue)
I’m working on the Trailhead project “Create and Test a Trigger”, where we need to automatically add a FREE Bouquet OrderItem when an Order is activated.
What I’ve done:
- Created a trigger on Order (before update)
- Implemented a utility class method to insert a bonus OrderItem
- Used logic to check when Order status changes from Draft → Activated
- Set:
- Quantity = 1
- UnitPrice = 0
- Description = 'FREE Bouquet'
Issue:
Even though the FREE Bouquet is successfully added to the Order (visible in Order Products), Trailhead still shows:
Current Trigger:
trigger orderTrigger on Order (before update) {
OrderItemUtility.addBonusBouquet(Trigger.new, Trigger.oldMap);
}
Key Logic:
- Using Trigger.oldMap to detect status change
- Inserting OrderItem inside before update to avoid ENTITY_IS_LOCKED error
Questions:
- What exactly does Trailhead validate behind the scenes?
- Is there any specific field (Description vs LineDescription) or condition it strictly checks?
- Are there any hidden requirements (like using a specific PricebookEntry or ProductCode)?
Would appreciate any guidance on why verification is failing despite correct functionality.
#Trailhead Challenges
Hi @Tisha Bakarwale - Most likely reasons your check is failing:
- Trigger must be exactly:
trigger orderTrigger on Order (before update) {
OrderItemUtility.addBonusBouquet(Trigger.new);
}
(no oldMap in signature)
- Bonus item must use correct Product + PricebookEntry (not just Description = 'FREE Bouquet')
- Must use Standard Price Book
- Must detect Draft → Activated inside utility class
- Enable New Order Save Behavior should be disabled in setup