salesforce - Apex Triggers - Trailhead -
the code doesn't give errors, anytime run trailhead gives me message:
"challenge not yet complete... here's what's wrong: executing trigger did not work expected. "
here instructions:
for challenge, need create trigger that, before insert or update, checks checkbox. if checkbox field true, sets shipping postal code (whose api name shippingpostalcode
) same billing postal code (billingpostalcode
).
- the apex trigger must called
accountaddresstrigger
. - the account object need new custom checkbox should have field label 'match billing address' , field name of
match_billing_address
. resulting api name shouldmatch_billing_address__c
. - with
accountaddresstrigger
active, if account has billing postal code ,match_billing_address__c
true, record should have shipping postal code set match on insert or update.
my code:
trigger accountaddresstrigger on account (before insert,before update) { for(account : [select id account match_billing_address__c = true , billingpostalcode != null]) { a.shippingpostalcode = a.billingpostalcode; update a; }//end }
your trigger way.
trigger accountaddresstrigger on account (before insert,before update) { //iterate accounts updated or inserted. for(account acc :trigger.new){ //if match true set values. if(acc.match_billing_address__c){ acc.shippingpostalcode = acc.billingpostalcode; } } }
Comments
Post a Comment