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
mukesh gupta 8mukesh gupta 8 

Trailhead Trigger Issue

Hi Expert,

I am doing trailhead trigger and using code this

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
       If (a.Test_LightingCo__Match_Billing_Address__c == true && a.Test_LightingCo__BillingPostalCode__c != Null) {
            a.Test_LightingCo__ShippingPostalCode__c = a.Test_LightingCo__BillingPostalCode__c ;
        }   
    } 
}

but code is working fine and Account object records update perfect. but if i clicks on "check chellange" button on trailhead trigger page then  , i got an error 
User-added image

Please suggest

Thanks
Mukesh

 
sfdcMonkey.comsfdcMonkey.com
hi Mukesh
create new custom field with name
Match_Billing_Address__c and type is checkbox on account object and try below trigger code
 
trigger AccountAddressTrigger on Account (before insert ,before update) {
    for(Account a: trigger.new){
        if(a.Match_Billing_Address__c && a.BillingPostalCode  != NULL)
            a.ShippingPostalCode = a.BillingPostalCode ;
    }
    
}
Thanks
Mark it best answer if my answer helps you :)

 
mukesh gupta 8mukesh gupta 8
Hi piyush,

Trigger functionality is working fine and i have already created "Match_Billing_Address__c" checbox. 

 
mukesh gupta 8mukesh gupta 8
Hi Piyush,

But issue is raised on check chellange button.

Please suggest