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
dgindydgindy 

Checking for Null returns

Ok.  This would seem like a simple answer to find. I could be asking the wrong question. 
Code:
Overnight__c[] Overnight = [select Doctor__c,Oximetry__c,Patient__c,Task__c,Scheduled_Date__c,PCCName__c,id from Overnight__c where Oximetry__c=:OxTest[0].Id];

if(Overnight[0].Id != null)

 
I get an out of index error.  nullvalue()? What should I be using to check if I have a data set being returned.
 
Thanks
Ron HessRon Hess
first you must check that you got a record back, no records should produce an empty array in overnight.
then you can check the first entry of the array

so, something like this

if (  overnight.size() > 0 )
   if ( overnight[0].id !=null )
dgindydgindy
Thanks