You need to sign in to do that
Don't have an account?
DevilJ
Need help with an empty SObject List
Hello Everyone,
I need some help with a bit of apex code. I am creating a query list that I need to check to see if it is empty.
Here is my code:
if (oldPhoneName != null){ List<Transportation_Services__c> oldRecord = [Select Name, Pickup_Time__c, Client__r.Last_Name__c, Pickup_Location__r.Name, Drop_Off_Location__r.Name, Phone_Name__c, Notes_Transportation__c from Transportation_Services__c WHERE Pickup_Time__c = TODAY AND Phone_Name__c = :oldPhoneName AND Name != :valueTwo Order by Pickup_Time__c]; if(oldRecord.isEmpty){ createXML(record, oldPhoneName, true); }else{ createXML(oldRecord, oldphoneName, false); } }
Apex does not like my 'records.isEmpty'. I get this error on compile:
Save error: Initial term of field expression must be a concrete SObject: LIST<Transportation_Services__c>
Does anyone know of a way that I can check if a SOQL generated list came back with no records (empty)?
Thanks.
You are missing the parentheses
All Answers
You are missing the parentheses
It bit simple, try this :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
OK...I'm gonna crawl back into my newbie hole now.....sorry!!
Thanks guys.
(I'm such an idiot......)
Nah, it always helps to have a second set of eyes look at something.
Would you mind marking either my post or Ankit's post as the solution, and not your own?
Thanks,
Mark