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
Alvin Dutt 6Alvin Dutt 6 

SOQL Query not returning results

Hello, 

I have ran into what seems to be a SOQL issue in either: query syntax or I've discovered a bug. I state that this might be a either a query syntax issue or a bug based on the premise that I've searched for clues and I've found nothing. 

Anyways, I have created a custom view. This custom view is titled "Leads Test Cadinal". In this, I have added only 1 contact. I've populated the company field with "Cadinal Inc". 

Now what I'm trying to do is fetch that contact with the company name "Cadinal Inc" (for that particular view obviously). When I execute the SOQL I get no hits returned from Salesforce despite the contact existing in the list. 

Now onto the more techincal details: 

I invoke the describe query in order to find the query that I want to execute to get that particular contact out. This is the query I receive after invoking the describe call
"SELECT Name, Company, State, Email, toLabel(Status), CreatedDate, Owner.Alias, IsUnreadByOwner, Id, LastModifiedDate, SystemModstamp, Owner.Id, OwnerId FROM Lead WHERE IsConverted = false AND Company like '%Cadinal%' ORDER BY Name ASC NULLS FIRST, Id ASC NULLS FIRST"
When I receive the query from the describe call, the query that I will use to fetch the contact in the list is the following: 
"/services/data/v38.0/query?q=SELECT id , email, Company FROM Lead WHERE IsConverted = false AND Company like '%Cadinal%' ORDER BY Name ASC NULLS FIRST, Id ASC NULLS FIRST"
Now what I am confused in is why the query fails to fetch the record? My hypothesis is that Salesforce keeps 
%Ca%
As a reserved word. I do not know why this query fails, can someone point me in the right direction on how to correctly query this. 

The following is a screen shot of my sample lead: 
Cadinal sample lead
Thanks, looking forward to some responses. 
GauravGargGauravGarg
Hi Alvin,

Please try to search Lead with "Name" on developer console and keep filter fields in select statement. 

Hope this might helps.

Thanks,
Gaurav
Skype: gaurav62990