You need to sign in to do that
Don't have an account?
Eddie Lott
Unusual Trigger Problem
Taking the challenge for the Getting Started With APEX triggers and found that the trigger code below did not work and had the stranger problem of Changing the Match_Billing_Address__c field to True whenever i tried to save an account. After a few exasperating hours, i changed I (a.Match_Billing_Address__c=true) to (a.Match_Billing_Address__c<>false) and it all started working and I passed the challenge. I would be grateful for any explanation of this behavior.
trigger AccountAddressTrigger on Account (before insert, before update) { For (Account a : Trigger.new) { If (a.Match_Billing_Address__c=true) { system.debug(a.Match_Billing_Address__c); a.ShippingPostalCode=a.BillingPostalCode; } } }
Best Answer chosen by Eddie Lott
Paul S.
It should have been:
What you were doing - and this will explain the "stranger problem" - was setting that checkbox to true ("=" assigns a value, "==" evaluates equality) which then caused the IF statement to evaluate to TRUE.