19 votes
Accepted

Ambiguous method signature on NULL value

The compiler cannot figure out which method to call here in the anonymous window because you are calling with 'null' explicitly vs having a variable type which it can use to figure out what you want. ...
Matt Comer's user avatar
14 votes
Accepted

Null check OR isEmpty Check

The straight SOQL accounts = [select id, .. from Account ...] always returns a list You can usually avoid even having to test for list empty by coding your methods to accept lists as arguments and ...
cropredy's user avatar
  • 71.3k
13 votes

Lightning Component Visibility filter to check if value is null

use <aura:if> to render the component based on the input of the text area. Pseudo code. <aura:component> <aura:attribute name="strTest" type="String"/> <aura:if isTrue="{!...
Samir's user avatar
  • 2,669
11 votes

Null List VS Empty List

Your assumption is incorrect and leadList1 will actually be an empty list. You would get an error if you tried: Lead singleLead = [SELECT Id FROM Lead LIMIT 1]; The reason such an assignment would ...
Adrian Larson's user avatar
  • 150k
8 votes
Accepted

Lightning Component Visibility filter to check if value is null

Use the empty string value '':
sfdcfox's user avatar
  • 490k
8 votes

JSON.serialize: is it possible to suppress null values of a map?

Yep, that's the expected behavior. For simple maps, you can get rid of null values by iterating over the map keys, keeping track of which ones have null values, and then a little map manipulation. ...
Derek F's user avatar
  • 61.5k
7 votes

Null check OR isEmpty Check

Generally speaking, null values should be rare, and you should treat them as such. The results of a query always results in a list, even though it may be an empty list. Querying a checkbox field from ...
sfdcfox's user avatar
  • 490k
7 votes

Attempt to de-reference a null object: list initialization

static methods share state (in the form of static variables) only in the context of a single transaction. Each Lightning server call to an @AuraEnabled method takes place in a separate transaction; no ...
David Reed's user avatar
  • 92.8k
7 votes
Accepted

A Variable Passed from my LWC to Apex Becomes Null

Your Apex parameters must be named exactly as stated in Javascript. Compare filters with jsonFilters.
Felix van Hove's user avatar
6 votes
Accepted

Null List VS Empty List

The results of a query are never null. An individual record at a given index in the results list will also never be null. Individual fields, however, can be null if they contain no data. If there are ...
sfdcfox's user avatar
  • 490k
5 votes
Accepted

RestContext.request.params.get gives null value for Test Class

You need to actually set the RestContext.request in your test class and then set any params you want through that. RestContext.request = new RestRequest(); RestContext.request.params.put('...
Adrian Larson's user avatar
  • 150k
5 votes

Null List VS Empty List

in addition to the excellent answers by sfdcfox and adrian, you actually want SOQL queries to return lists (empty or otherwise) Why? A well-written apex class will almost never check for null when ...
cropredy's user avatar
  • 71.3k
5 votes
Accepted

Adding null to Set<Id> doesn't return an empty Set

What you have observed is expected behavior: null is a valid collection element, and containing it makes the collection non-empty.
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Null pointer exception using null safe navigation operator

Yes, it is compiled to essentially if(sample == null? null: sample.SomeField__c). However, if(null) isn't valid. Just compare to true or false depending on your need. if(sample?.SomeField__c == true) {...
sfdcfox's user avatar
  • 490k
4 votes
Accepted

Can apex:param pass null for Integers?

It looks like the problem is that when the parameter comes over as an empty string, salesforce converts the value to 0 instead of NULL. You could consider setting the value of index in your method ...
martin's user avatar
  • 12.6k
4 votes

What Criteria to use in Process Builder to check for NULL reference?

Well, I've just experienced a similar issue, but it's not exactly the same as yours. In my case, the cause of the error was that I set the condition if the id of referenced record is null. I had to ...
Keisuke's user avatar
  • 41
4 votes

What Criteria to use in Process Builder to check for NULL reference?

I faced the exact same problem with Process Builder and then the following solution helped. Whenever we are referring a related record in Process Builder we should put a NULL value check for that ...
Rosh's user avatar
  • 41
4 votes
Accepted

Null values isn't seen as null

You should be using ISBLANK instead. ISNULL is used for types of values like numbers and dates, but formulas evaluate text fields to an empty string (a "blank") if they contain no data. Use ISBLANK ...
sfdcfox's user avatar
  • 490k
4 votes

How to insert/pass NULL value into Date field

You need to use the fieldsToNull attribute, as noted in the update documentation. $createField["fieldsToNull"] = array("Date__c");
sfdcfox's user avatar
  • 490k
4 votes
Accepted

Filter NULL values in reports?

If you want a not null field, just set the field not equal to blank, i.e., leave the filter value box empty.
Ajay Prakash Dubey's user avatar
4 votes
Accepted

Try/Catch for Attempt to Dereference Null Object

The problem is that you're not checking for null in time. There's no need to use try-catch (and you shouldn't, because they are incredibly expensive CPU-wise). The appropriate way would be to do this: ...
sfdcfox's user avatar
  • 490k
4 votes

Database.Query does not return fields with null value

If you are checking in the debug logs, then that is how it will be displayed. It behaves the same for the normal SOQL query as well as for the dynamic SOQL i.e. with Database.Query So, if you perform ...
Vijay Ganji's user avatar
  • 6,606
4 votes
Accepted

Apex object returning null

This is because of "name shadowing." You named both the parameter e and the property e, so you're just assigning the value to itself (i.e. nothing happens). You need to use this if you ...
sfdcfox's user avatar
  • 490k
4 votes
Accepted

Flow: "Is Null" does not work for compound fields?

I opened a case with Salesforce support and they said Flow decision criteria do not support compound fields. However, in their testing they discovered that Flow formula variables do not support ...
David Cheng's user avatar
  • 7,085
4 votes

attempt to de-reference null object when using maps to build parent-child relationship for visualforce page

When you run into an NPE (Null Pointer Exception), you always have something in your code that partially evaluates to null.<something else>. null is a special type/value thing. It has no ...
Derek F's user avatar
  • 61.5k
3 votes
Accepted

How to handle optionally null related objects in process builder?

For some time now, SFDC has recommended that one use ISBLANK(..) in lieu of ISNULL(..). As Matt Lacey describes, ISNULL behaves differently for text and lookup fields than ISBLANK. So, rewrite your ...
cropredy's user avatar
  • 71.3k
3 votes
Accepted

Making "Null" as "" in JSON payload

You should just serialize a Map<String, String>: Map<String> data = new Map<String, String> { 'displayName' => acc.Display_Name__c, 'bioUrl' => acc.Bio_URL__c, '...
Adrian Larson's user avatar
  • 150k
3 votes
Accepted

Attempt to de-reference a null object - Error in sorting list

If this is the line that is throwing the error: surveyInstanceListsorted.add(sq); // This line throws error. The most likely scenario is that ahead of this block of code which you're showing us ...
Mark Pond's user avatar
  • 23k
3 votes
Accepted

Assertion failure that a null pointer exception is caught

Exceptions have a type (e.g. "NullPointerException") and a message (e.g. "Argument cannot be null") and perhaps most usefully of all a stack trace (the line number and class name that the exception ...
Keith C's user avatar
  • 136k
3 votes
Accepted

Trigger will not fire, picklist value always returns null

An answer to your issue about not being able to do this trigger's work without performing DML in a loop... you've just got to get a little fancier in your implementation. trigger NewProposalPQ on ...
Mark Pond's user avatar
  • 23k

Only top scored, non community-wiki answers of a minimum length are eligible