I have a custom field that is populated by integration, and in certain cases a currency field will end up as blank. It will not evaluate to null or 0.

SQL Execute from dev console log:

13:26:53:006 SOQL_EXECUTE_BEGIN [2]|Aggregations:0|SELECT Id, Name, Last_Year_Sales__c FROM Account WHERE ((Last_Year_Sales__c = 0 OR Last_Year_Sales__c = NULL) AND Id = '0010y00001Y0cOWAAZ')

Results from Dev console log:

13:26:53:010 VARIABLE_ASSIGNMENT [2]|accts|[{"Id":"0010y00001Y0cOWAAZ","Name":"TEST ACCOUNT"}]|0xe6fce69

The field Last_Year_Sales__c is included in the SELECT and the WHERE Clauses, and I'm getting the correct # of records (1), but the field Last_Year_Sales__c is not available in the returned list, so I cannot check if it is null or 0.

How do I get around this?

Thanks in advance.

  • Whats the Field Level Security for Last_Year_Sales__c ? do you have atleast read access? Mar 5, 2019 at 18:32
  • Can you add more code? Mar 5, 2019 at 19:58

2 Answers 2


You might not have access to the field. You can go to your assigned profile and give FLS there.

  • Yes - the field is editable, and if I issue the query for an Account record that already has the field populated with a 0 or a calculated amount, there's no issue.
    – Shawn A
    Mar 5, 2019 at 19:31

It's just the system.debug which is not showing you the value null, but the field is infact returned with the query. Most likely the way the JSON is being deserialized in the debug log, it is skipping any null field values.

So you can always compare the value being returned by the field with null value, e.g., myObj.Last_Year_Sales__c == null, this will work fine.

As an example, I tried the below query in my DE Org where AnnualRevenue was set to null.


List<Account> aList = [SELECT Id, Name, AnnualRevenue FROM Account where Id = 'xxxx'];
Account a = aList.get(0);
system.debug('My Account: ' + a);

This is what I got in the debug log, the field was never printed.

USER_DEBUG [3]|DEBUG|My Account: Account:{Id=xxxx, Name=United Oil & Gas Corp.}

And, the below condition to verify null worked just fine:

if(a.annualrevenue == null) {
    system.debug('It is null!');
} else {
    system.debug('It is NOT null!');

And the result was:

USER_DEBUG [6]|DEBUG|It is null!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .