简体   繁体   English

SOQL查询类似运算符不返回结果

[英]SOQL Query Like Operator not returning results

I have ran into what seems to be a SOQL issue in either: query syntax or I've discovered a bug. 我遇到了以下一种似乎是SOQL的问题:查询语法或我发现了一个错误。 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". 此自定义视图的标题为“ Leads Test Cadinal”。 In this, I have added only 1 contact. 在此,我仅添加了1个联系人。 I've populated the company field with "Cadinal Inc". 我在“公司”字段中填充了“ Cadinal Inc”。

Now what I'm trying to do is fetch that contact with the company name "Cadinal Inc" (for that particular view obviously). 现在,我要尝试的是获取与公司名称“ Cadinal Inc”的联系(显然是针对该特定视图)。 When I execute the SOQL I get no hits returned from Salesforce despite the contact existing in the list. 当执行SOQL时,尽管列表中已有联系人,但Salesforce都没有返回任何匹配。

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. 我调用describe查询,以查找要执行的查询以使该特定联系人退出。 This is the query I receive after invoking the describe call 这是我在调用describe调用后收到的查询

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: 当我从describe调用收到查询时,将用于获取列表中联系人的查询如下:

/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 /services/data/v38.0/query?q=选择id,电子邮件,潜在客户所在的公司IsConverted = false AND公司,例如'%Cadinal%'顺序按名称ASC开头为空,Id ASC开头为空

Now what I am confused in is why the query fails to fetch the record? 现在让我感到困惑的是,为什么查询无法获取记录? My hypothesis is that Salesforce keeps 我的假设是Salesforce会继续

%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: 以下是我的示例线索的屏幕截图:

潜在客户视图

Thanks, looking forward to some responses. 谢谢,期待一些答复。

Please URL Encode the SOQL Query before making the REST call. 请在进行REST调用之前对SOQL查询进行URL编码。 Something like below should work : 像下面这样的东西应该工作:

/services/data/v38.0/query?q=SELECT+id+%2C+email%2C+Company+FROM+Lead+WHERE+IsConverted+%3D+false+AND+Company+like+%27%25Cadinal%25%27+ORDER+BY+Name+ASC+NULLS+FIRST%2C+Id+ASC+NULLS+FIRST /services/data/v38.0/query?q=SELECT+id+%2C+email%2C+Company+FROM+Lead+WHERE+IsConverted+%3D+false+AND+Company+like+%27%25Cadinal%25%27 + ORDER BY +姓名+ ASC + + + NULLS FIRST%2C +编号+ ASC + NULLS + FIRST

Reference : https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm 参考: https : //developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM