0

I am VERY new to apex coding and am trying to figure out why the trigger below gets the "Compile Error: Method does not exist or incorrect signature: [MAP].containsKeys(Id) at line 10 column 13". I also want to make sure I test this properly. I will include the test class below too.

TRIGGER

trigger DeleteATM on Account(after insert, after update) {

    map<Id,AccountTeamMember> account2TeamMemberMap = new map<Id,AccountTeamMember>();
    for(AccountTeamMember mem : [Select Id, AccountId From AccountTeamMember Where TeamMemberRole = 'Customer Success Manager' and AccountId In : trigger.new]){
        account2TeamMemberMap.put(mem.AccountId, mem);
    }

    list<AccountTeamMember> members2Delete = new list<AccountTeamMember>();
    for(Account acc: Trigger.new){
        if (account2TeamMemberMap.containsKeys(acc.Id) && acc.Customer_Success_Manager__c == null) {
            members2Delete.add(account2TeamMemberMap.get(acc.Id));
        }
    }
    delete members2Delete;
}

TEST CLASS

@isTest
Public class RemoveCSMTest {
    Static testMethod void insertNewAccount() {
        Account Cre = new Account();
        Cre.Market__c = 'Houston';
        Cre.Business_Unit__c = '334';
        Cre.Name = 'Test CSM2';
        Cre.Customer_Success_Manager__c = '005A0000000SAC0';
        Insert cre;
        List<Account> a = [SELECT Id, Name, Customer_Success_Manager__c FROM Account WHERE Name = 'TestCSM2']; 
        for (Account accs : a){
            accs.Customer_Success_Manager__c=NULL;
            Update accs;
        }
    }
}
4

This is just a typo. the method is containsKey(), you have containsKeys(). Try removing the 's'

account2TeamMemberMap.containsKey(acc.Id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.