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
TraceyTracey 

Updateing Accounttammeber object via Trigger issue

 

Could somebody please let me know why I can update AccountAccessLevel field on the AccountTeamMember object?

 

 public class Acceleration_CollaborativeTeam {
     public static void updateAccountTeam(id accountid, id userid , string role, string action)
    {
        Boolean existingrecord = false;
        List<AccountTeamMember> atmlist = new List<AccountTeamMember>();
        for (AccountTeamMember atm : [select UserId, TeamMemberRole,Id,CreatedById,AccountId, AccountAccessLevel  from AccountTeamMember where (AccountId = :accountid and UserId =: userid and TeamMemberRole =: role)]) {
            existingrecord = true;
        }

              
        if (existingrecord = true)
        {     
            AccountTeamMember newatm = new AccountTeamMember();
            
            newatm.AccountId =  accountid;
            newatm.UserId= userid;

            newatm.TeamMemberRole = role;
          //  newatm.AccountAccesslevel = 'Read';

            atmlist.add(newatm);
        }

        if (atmlist.size() > 0) {
            insert atmlist;
        }
    }


}