You need to sign in to do that
Don't have an account?

Challenge Not yet complete... here's what's wrong: Setting 'Match_Billing_Address__c' to true did not update the records as expected.
I'm getting the same error even though I'm using the code provided by other users here. The new field is also created.
Is there anything wrong with it?
Thanks in advance.
trigger AccountAddressTrigger on Account (before insert, before update) { for(Account a : Trigger.new){ If (a.Match_Billing_Address__c == true) { a.ShippingPostalCode = a.BillingPostalCode; } } }
Is there anything wrong with it?
Thanks in advance.
I just fixed the problem! For some reason the Trigger was inactive. I actived it and checked the Challenged and worked properly!
Best,
Dannilo
All Answers
Can you pls tell me what error you are getting. It's working fine in my dev account.
Thanks,
Sumit Kumar Singh
I'm getting the following error:
Challenge Not yet complete... here's what's wrong:
Setting 'Match_Billing_Address__c' to true did not update the records as expected.
I created the Match Billing Address property and I rewrote my code like suggested in other posts but I'm still getting this error.
Any ideas? Can it be my dev account?
Thanks,
Dannilo
I just fixed the problem! For some reason the Trigger was inactive. I actived it and checked the Challenged and worked properly!
Best,
Dannilo
for(Account a : Trigger.new){
/* from below if statement (a.BillingPostalCode != null) checks "if an Account has a Billing Postal Code" from challenge
if(a.BillingPostalCode != null && a.Match_Billing_Address__c == true){
a.ShippingPostalCode = a.BillingPostalCode;
}
}
}
kindly help me with this.
-----> We updated an account that had 'Match_Billing_Address__c' set to false. We expected the Apex trigger not to fire, but it did. Make sure the Apex trigger fires only if 'Match_Billing_Address__c' is true.
If Anyone has done this Please How to solve it.
trigger AccountAddressTrigger on Account (before insert, before update) {
for (Account a : Trigger.new) {
a.AccountNumber = '12345678';
if (a.Match_Billing_Address__c == true) {
a.ShippingPostalCode = a.BillingPostalCode;
}
}
}
for some reason i had to remove {} after IF statement...
trigger AccountAddressTrigger on Account (before insert, before update) {
for(account add: Trigger.new){
if(add.Match_billing_address__c == True)
add.ShippingPostalCode = add.BillingPostalCode;
}
}
for me, it was fixed by making other triggers inactive and only this one as active.
Reason 1: threre is no record already existed in the field so its been showing like empty and stopping the trigger to set the value.
Reason 2: if there already another account object trigger on stand it hard to execute the same trigger at a time.
I've used the following code to add a value to the field :
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account acc:Trigger.new)
{
acc.AccountNumber = '1234567';
if(acc.Match_Billing_Address__c == true)
acc.ShippingPostalCode = acc.BillingPostalCode;
}
}
and i've tried the challenge with another playground of different org account . So it got triggered successfullyand completed my challenge
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account acct : Trigger.new){
if(acct.Match_Billing_Address__c == True){
acct.ShippingPostalCode = acct.BillingPostalCode;
}
}
}
https://youtu.be/sqIkewmXOZk
After you have created this trigger make sure to follow along with this tutorial, you can skip to the part where he creates the code. To test your trigger go into Saleforce classic and create a new Account record, titled whatever and make sure the match billing address is checked. Fill in the shipping address and billing address and make sure they match (you can use a seudo adress or your own).
Last step (VERY IMPORTANT) to be able to create your new account record and test the trigger to pass the test you MUST go to your AddRelatedRecord Trigger and deactivate it because that trigger is ran when creating the record, otherwise you will get an error, after you finished that you can then succesfully complete the trailhead! Hoped it helps!!!
trigger AccountAddressTrigger on Account (before insert,before update)
{
//Condition: Match Billing Address is true
//Operation: set the Shipping Postal Code to match the Billing Postal Code
for (Account a:trigger.new)
{
if(a.Match_Billing_Address__c==true && a.BillingPostalCode != null)
{
a.ShippingPostalCode=a.BillingPostalCode;
}
}
}
Issue i am facing is: We updated an account that had 'Match_Billing_Address__c' set to false. We expected the Apex trigger not to fire, but it did. Make sure the Apex trigger fires only if 'Match_Billing_Address__c' is true.
Try using other org where you don't have any trigger on Account object. It will work.
If you liked my answer and it solved your issue, please mark it best answer.
Thanks,
Payal