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
brozinickrbrozinickr 

Initial term of field expression must be a concrete SObject

Hello,

 

I was wondering if someone would be able to help me fix my code.  The premise of what I am trying to do is whenever a lead is created, if Storefront is selected in the Lead_Direction__c picklist, assign it to the listed Storefront Associate in the Account Team for the particular Account.  If Big Deal is selected in the Lead_Direction__c picklist, assign it to the Big Deal Associate listed for the particular Account's Account Team.

 

I am pretty sure this probably isn't the prettiest and concise way to go about doing this either, so if there's an entirely easier way to get the end result, I am completely open to changing my code.

 

This the error I am getting and highlighted the line below:

 

Initial term of field expression must be a concrete SObject: LIST<AccountTeamMember> at line 13 column 61

 

trigger LeadAssignmentTrigger on Lead (before insert){

    for (Lead lead : Trigger.new){
         
      if (lead.Account__c != NULL){
      
          // Find the Account Team Member for the Particular Lead
          List<AccountTeamMember> account = [SELECT AccountId,UserId,TeamMemberRole FROM AccountTeamMember where Accountid = :lead.Account__c limit 2];
                
          // if you found one
          if (account.size() > 0) {

              if((lead.Lead_Direction__c == 'Storefront')&&(account.TeamMemberRole == 'Storefront Associate')){
              
              //assign the lead owner to the Storefront Owner
              
              lead.OwnerId = account[0].UserId; 
              
              }
              
              else if ((lead.Lead_Direction__c == 'Big Deal')&&(account.TeamMemberRole == 'Big Deal Associate')){
              
              //assign the lead owner to the Big Deal Owner
              
              lead.OwnerId = account[0].UserId;
              
              }
          
          }
       } 
          
     }
          
}

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul_sgRahul_sg
here account is a list so try using account[0]

All Answers

Rahul_sgRahul_sg
here account is a list so try using account[0]
This was selected as the best answer
brozinickrbrozinickr

Thank you! :)