You need to sign in to do that
Don't have an account?
Boudewijn Timmers
Apex triggers trailhead challenge question
Again I need to ask this as I am not sure what Apex triggers trailhead challenge expects from me. Need to create a trigger that checks if Match_Billing_Address__c is checked and if BillingPostalCode is not empty. In that case set ShippingPostalCode__c to match BillingPostalCode. My code works, it behaves as expected but the challenge won't accept it.
What is wrong with my code?
regards,
boudewijn
trigger AccountAddressTrigger on Account (before insert, before update) { for(Account a : Trigger.new){ If(a.Match_Billing_Address__c) { If(a.BillingPostalCode != ''){ a.ShippingPostalCode__c = a.BillingPostalCode; } } } }
What is wrong with my code?
regards,
boudewijn
trigger AccountAddressTrigger on Account (before insert ,before update) {
for(Account accnt : trigger.new){
if(accnt.Match_Billing_Address__c && accnt.BillingPostalCode != NULL)
accnt.ShippingPostalCode = accnt.BillingPostalCode ;
}
}
Thanks :)
All Answers
trigger AccountAddressTrigger on Account (before insert ,before update) {
for(Account accnt : trigger.new){
if(accnt.Match_Billing_Address__c && accnt.BillingPostalCode != NULL)
accnt.ShippingPostalCode = accnt.BillingPostalCode ;
}
}
Thanks :)
yes thanks, I just found out that I had created a shippingpostalcode__c myself even thoug the standard shipping address compound field already contains a shipping postal code. So upon changing it it worked!
Thanks, Boudewijn