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
Mehul pMehul p 

Comparison arguments must be compatible types: List<AccountTeamMember>, Schema.SObjectField

Hello Everyone,
       I am stuck on this error and I am not sure what  I am doing wrong.
 
trigger testTriggeronContact on Contact (before insert) {

List<Contact> contactCheck = new List<Contact>();
List<Account> AccountCheck = new List<Account>();
          

If(trigger.isBefore && trigger.isinsert){


For(Contact c : trigger.new){
     
     //Get contactId from Trigger

      string contactId = c.Id;

        
     //Gets Current AccountId Related to Contact
     Contact AccId = [SELECT AccountId FROM Contact WHERE Id = :contactId limit 1];
      
    //Gets Account Team Members from Account Related to Contact 
    List<AccountTeamMember> atmID =[Select UserId From AccountTeamMember WHERE AccountId  = :accId.AccountId ];

    for (User x : atmID){
          If (x == User.Id){
           some code here...
          }
          else{
            some code here....         
          }
        }

}
}
}
I am getting this error at line If( x==User.Id). 

Not sure How I can compare AccountTeamRoles UserIds to Contact's UserIds without getting an error?

Any guidance will be of great help.

Thank you,
 
Raj VakatiRaj Vakati
Try this  .. you loop must be with AccountTeamMember and not with user 
 
trigger testTriggeronContact on Contact (before insert) {

List<Contact> contactCheck = new List<Contact>();
List<Account> AccountCheck = new List<Account>();
          

If(trigger.isBefore && trigger.isinsert){


For(Contact c : trigger.new){
     
     //Get contactId from Trigger

      string contactId = c.Id;

        
     //Gets Current AccountId Related to Contact
     Contact AccId = [SELECT AccountId FROM Contact WHERE Id = :contactId limit 1];
      
    //Gets Account Team Members from Account Related to Contact 
    List<AccountTeamMember> atmID =[Select UserId From AccountTeamMember WHERE AccountId  = :accId.AccountId ];

    for (AccountTeamMember x : atmID){
          If (x == c.userId){
           some code here...
          }
          else{
            some code here....         
          }
        }

}
}
}