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
Jyosi jyosiJyosi jyosi 

Trying to write the Trigger using hanlder class "nitial term of field expression must be a concrete SObject: LIST<Account> at line 7 column 6"

Hello Everyone,

Trying to write the trigger using handler class.I am getting below error
nitial term of field expression must be a concrete SObject: LIST<Account> at line 7 column 6

Below is the intinal code

TRIGGER CLASS

trigger AccountTestTrigeer on Account (before insert, before update) {
    AccountTestTrigeerhandler handler = new AccountTestTrigeerhandler();
   
    if( Trigger.isInsert && Trigger.isbefore )
    {
        handler.OnAfterInsert( Trigger.New );
    }

}
####################



CALLING TRIGGER FROM THE BELOW CLASS.
public without sharing class AccountTestTrigeerhandler

{
  Account oAccount= new Account();
  public void OnAfterInsert()
  {
     oAccount.Industry = 'Cloud Computing';
  }
}

Thanks for the help
Abhishek_PareekAbhishek_Pareek
Hey Jyosi,

I'm not sure what are you trying to do. But, if you want to set the value of Industry field on account in Trigger.new list, this code should set Industry as "Cloud Computing" as we're iterating the incoming Trigger.new List in the helper class. In the above code, we're creating a new variable of type Account, which has no reference to incoming accounts in Trigger.new:

public without sharing class AccountTestTrigeerhandler

{
  public void OnAfterInsert(List<Account> accList)
  {
  	for(Account oAccount : accList){
  		oAccount.Industry = 'Cloud Computing';
  	}
  }
}
Let me know if it helps.