+ Start a Discussion
ravikanth321ravikanth321 

Null pointer exception when owner is inactive on contact object before update trigger.

Hii In this line of code ....              if(mapOfUserAssigns.containsKey(userinfo.getUserId()) && !mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r.isEmpty() && mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r[0].Authorized_States__c != null && mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r[0].Authorized_States__c.contains(cntObj.MailingStateCode)){
I am getting Null Pointer exception ,On one existing contact owner is inactive ,I am  just editing state field on contact and saving after saving i am getting nullpointer exception..!
 
Shweta_AgarwalShweta_Agarwal
Hi Ravi,

You need to replace "mapOfUserAssigns.containsKey(userinfo.getUserId())" with "mapOfUserAssigns.containsKey(cntObj.OwnerId)".
Hope this will solve your problem.

Thanks
Shweta