function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vidya BaskarVidya Baskar 

Trailhead challenge-The 'AccountTrigger' Trigger does not appear to be working correctly. Inserted records did not have matching BillingState and ShippingState values.

I'm trying to complete this trailhead challenge "Understand Execution Context". And getting this error message.
trigger AccountTrigger on Account (before insert) {
if(Trigger.isBefore && Trigger.isInsert)
{
    
    AccountTriggerHandler.CreateAccounts(Trigger.new);
        }

}

This is the trigger i'm using. Please advise.
Agustin BAgustin B
Hi Vidya, can you show me the CreateAccounts method?
According to the message the shippingState has to be equal to BillingState, please verify this.
AbhishekAbhishek (Salesforce Developers) 
Hi Vidya,

For all the Trailhead issues please report it here,

https://trailhead.salesforce.com/help?support=home#

https://trailhead.salesforce.com/help

So that our trailhead support engineers will look into it and get back to you.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Regards,
​​​​​​​Salesforce Support.
Vidya BaskarVidya Baskar
public class AccountTriggerHandler {
public static void CreateAccounts(List<Account> accts) {
    
        for (Account a : accts) {
            if(a.ShippingState!=a.BillingState)
               a.BillingState=a.ShippingState;
        }
    }
}
Agustin BAgustin B
Do you have State and Country picklist enabled? In that case you should use BillingStateCode and ShippingStateCode.
Also validate if you always have a value in ShippingState and BillingState. You could use a system.debug to check the value.