I'm getting the null pointer exception in for loop
FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
. Is there a way to filter null in Map.get()?
Map<ID,List<AccountPartner>>actIdPartnerMap= new Map<ID,List<AccountPartner>>();
// (populate map here...)
if (!actIdPartnerMap.isEmpty()) {
if(null != p:actIdPartnerMap.get(usr.AccountId)) {
for(AccountPartner p:actIdPartnerMap.get(usr.AccountId)) {
AccountShare acp = new AccountShare();
acp.AccountId=p.AccountFromId;
acp.UserOrGroupId=usr.id;
acp.AccountAccessLevel='Edit';
acp.CaseAccessLevel='Edit';
acp.OpportunityAccessLevel='Edit';
sharingObjects.add(acp);
system.debug(logginglevel.INFO,'InInnerLoop*******'+acp);
}
}
}