function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KaityKaity 

Developer Console Error: System.NullPointerException: Attempt to de-reference a null object

Hi-

I am writing this code snippet in Developer console:

List<Lead> ledLst = [Select Id, Name From Lead where ID IN : Trigger.NewMap.keySet()];
System.debug('$$$$$$$'+ledLst);


But, I am getting the beloe Error:

System.NullPointerException: Attempt to de-reference a null object.

What is wrong in my snippet?

Thanks,
Kaity
 
Shaijan ThomasShaijan Thomas
You can not user trigger variable in Developer Console
 
KaityKaity
Thank you Shaijan.
Has SalesForce mentioned that concept in any Apex Guide or Document. Actually, I have read once the Apex Guide, But I didnot see that limitation. 

-Kaity
Shaijan ThomasShaijan Thomas
Trigger variables are context based variable. It can not user any where outside the Trigger. Its known concept, not sure where its mentioned
Shaijan Thomas
KaityKaity
You are correct Shaijan.  Many Thanks.
Want to know, Can we call trigger from Developer Console?

Thanks,
Kaity
 
Shaijan ThomasShaijan Thomas
No, we can not, understand more about trigger you will get to know more.
shaijan
Shaijan ThomasShaijan Thomas
If it was informative please check Best Answer