You need to sign in to do that
Don't have an account?
Shruthi MN 88
Invalid loop variable type expected SObject was Account
Hi Everyone,
I have the below trigger senario
On the Account object, When an account is inserted, automatically account Billing address should populate into the account shipping address.
I have created the below handler class I am getting the attached error:
public class AccountAddressTrigger {
public static void createAccount(List<Account> accounts) {
for(Account a:trigger.new){
if(a.ShippingAddress!=null){
a.ShippingCity = a.BillingCity;
a.ShippingCountry = a.BillingCountry;
a.ShippingPostalCode = a.BillingPostalCode;
a.ShippingStreet = a.BillingStreet;
a.ShippingState = a.BillingState;
}
}
}
}
I have the below trigger senario
On the Account object, When an account is inserted, automatically account Billing address should populate into the account shipping address.
I have created the below handler class I am getting the attached error:
public class AccountAddressTrigger {
public static void createAccount(List<Account> accounts) {
for(Account a:trigger.new){
if(a.ShippingAddress!=null){
a.ShippingCity = a.BillingCity;
a.ShippingCountry = a.BillingCountry;
a.ShippingPostalCode = a.BillingPostalCode;
a.ShippingStreet = a.BillingStreet;
a.ShippingState = a.BillingState;
}
}
}
}
In your handler class, you have defined the method createAccount that takes a parameter accounts of type List<Account>. However, based on the code, it seems like you are trying to access trigger context variables (trigger.new) directly within the handler method.
To properly use the trigger context variables within your handler, you need to pass them as arguments to the handler method from your trigger. Here's how you can do it:
Thanks,
Nishant