Whenever i am calling CampaignMember.getSobjectType() method , getting nullpointer exception. I tried to debug the CampaignMember object but getting null value object as well. Marketing User checkbox is checked on user record.
If you have a local variable or field in your class called
CampaignMember (case doesn't matter in Apex) that will shadow (hide) the SObject type name and generate the NPE is it is null at that point in the code.
A quick fix is to use:
But probably best to change the name of the variable or field.