0

Hi everyone I'm having a problem with a query over campaignmember object, Im trying to use In clause to filter by id , but it retrieves nothing, crazy thing is that the list actually has an id, and it belongs to a campaignmember record. This is my code, this method is being called from after delete

public void doNotAllowDeleteCampaignMembers(Map<ID,CampaignMember> oldMapCampaignMembers){
        String usrProfileName = [select u.Profile.Name from User u where u.id = :Userinfo.getUserId()].Profile.Name;
        system.debug('oldMapCampaignMembers.keyset():'+oldMapCampaignMembers.keyset());        
        for(campaignmember cmp:[SELECT Id, Campaign.RecordType.Name FROM CampaignMember WHERE Id IN :oldMapCampaignMembers.keyset() ]){
            system.debug('mCmRec.get(cm.id).Campaign.RecordType.Name:'+cmp.Campaign.RecordType.Name);
            //it never gets here since In clause its not detecting the id  
        }
}

Any ideas of what is going on?

1

By the way you have tagged your message it seems to me that you are running that code in an after delete trigger context. If the Ids you are using are the ones that are deleted, they are no longer available for query on the after part of the trigger. (They are supposed to count as deleted, hence they are no longer returned by the SOQL Query)

| improve this answer | |

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.