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
reem sharawyreem sharawy 

Updating team member object on delete method

Hi All

I am trying to update my Team_Member__c object on delete method for account share to change account access for 'read/writte' to 'read' but it's not doing any action on my page
 
//The Logic for the Delete  the Account Team Member
    if(teamMemberDeleteMap.size() > 0)
    {
        List<AccountTeamMember> accountTeamMemberDeleteList = new List<AccountTeamMember>();
        
        //Query to the List...
        List<AccountTeamMember> accountTeamMemberList = new List<AccountTeamMember>([Select UserId, TeamMemberRole, Id, AccountId, AccountAccessLevel From AccountTeamMember where AccountId IN : accountIdsSet]);
  
        List<AccountShare> AccountShareList = new List<AccountShare>([Select UserOrGroupId, AccountId, AccountAccessLevel  From AccountShare where AccountId IN : accountIdsSet]);
        
        List<Team_Member__c> remainteammemberList = new List<Team_Member__c>([Select Team_Member__c , Account_Access__c, Account__c From Team_Member__c  where Account__c IN : accountIdsSet]);
        
        for(AccountTeamMember teamMember : accountTeamMemberList)
        {
            //System.debug('The Account Team : '+ teamMember.AccountId+''+teamMember.UserId );
            //For Update....
            if(teamMemberDeleteMap.get(teamMember.AccountId+''+teamMember.UserId) != null)
            {
                accountTeamMemberDeleteList.add(teamMember);
            }
        }
            for(Team_Member__c  teammemberObject : remainteammemberList )
        {
            teammemberObject.Account_Access__c = 'Read';
        }
        
        //Deleting the Records...
        if(accountTeamMemberDeleteList.size() > 0)
            upsert remainteammemberList ;
            delete accountTeamMemberDeleteList;
    }