You need to sign in to do that
Don't have an account?
Akshada Sonavane 2
Error while checking a trigger challebge on trailhead(trigger to set the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).if the checkbox 'Match_Billing_Address__c' is true)
For this trigger trailhead question:
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).
The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.
Getting following error while checking the challenge on trailheads:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).
The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.
Getting following error while checking the challenge on trailheads:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject
All Answers
Try, this code to pass your challenge, maybe there was some little error in your code.
I Hope, this will helpful to pass the challenge, if it helps you, please mark this answer as solved.
Regards
Suraj
{
for(Account a:trigger.new)
{
if(a.Match_Billing_Address__c==True && a.BillingPostalCode != NULL)
{
a.ShippingPostalCode=a.BillingPostalCode;
}
}
}
}
for(Account a: Trigger.new){
if(a.Match_Billing_Address__c==true){
a.ShippingPostalCode=a.BillingPostalCode;
}
}
}
This just works fine! Hope it helps.