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
imhereimhere 

queryResult.getRecords return Null ??? while isDone returns TRUE

Hi
I am Querying CustomObject__c.
If i set Where clause on Name Field it workds fine ... But if i set Where Clause to myCustomField__c It executes the Query (query.isDone() is TRUE) . But throws NullPoiterException on queryResult.getRecords()

Name and myCustomField have the same values.

what is the best practice to Query a CustomObject__c ??

here is the TWo differnt Codes i am using ...

NO ERRORS Query:
query("select Area_ID__c, Service_ID__c from UserService__c where Name='"
+ name + "'");

NULLPOINTER QUERY:
query("select Area_ID__c, Service_ID__c from UserService__c where myCustomField ='"
+ name + "'");
Sean_kSean_k
Per my understanding isDone returning true means there are nomore records available in the QueryResults object...are you still trying to get records even isDone == true...send your if condition code..
--Sean
SuperfellSuperfell
most toolkits will return null for an empty array. So if getRecords() returns null, it means there's no matching records.
imhereimhere
thx Alot SeanK and SimonF for your kind and immediate replies.

SimonF you are right actually there were no matching records.

I was trying to fetch records of AdjacentArea__c that has relationship with Area__c and other CustomObjects__c
what i was doing ... I was trying to fetch the Record " SELECT customField__c1, .... ..... FROM AdjacentArea__c Where Area__c=VALUE "
I was replacing value with the NAME Field of Area ... It was returning No Result. Because Area__c does not have the name value instead it has the ID value of Area__C Object.