没有合适的资源?快使用搜索试试~ 我知道了~
Salesforce SOQL和SOSL参考手册
需积分: 5 0 下载量 96 浏览量
2024-05-25
16:01:09
上传
评论
收藏 1.58MB PDF 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/89355330/0001-93db26a861b25a5a4b2829a9c677d1ac_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
128页
SOQL(Salesforce Object Query Language,Salesforce对象查询语言) SOSL(Salesforce Object Search Language,Salesforce对象搜索语言)
资源推荐
资源详情
资源评论
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![msi](https://img-home.csdnimg.cn/images/20210720083646.png)
![exe](https://img-home.csdnimg.cn/images/20210720083343.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/release/download_crawler_static/89355330/bg1.jpg)
SOQL and SOSL Reference
Version 61.0, Summer ’24
Last updated: May 17, 2024
![](https://csdnimg.cn/release/download_crawler_static/89355330/bg2.jpg)
©
Copyright 2000–2024 Salesforce, Inc. All rights reserved. Salesforce is a registered trademark of Salesforce, Inc., as are other
names and marks. Other marks appearing herein may be trademarks of their respective owners.
![](https://csdnimg.cn/release/download_crawler_static/89355330/bg3.jpg)
CONTENTS
Chapter 1: Introduction to SOQL and SOSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: Salesforce Object Query Language (SOQL) . . . . . . . . . . . . . . . . . . . . . . . . . 3
Typographical Conventions in This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Quoted String Escape Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Reserved Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Alias Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
SOQL SELECT Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
SELECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
TYPEOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
USING SCOPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
WHERE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
WITH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
GROUP BY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
HAVING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
ORDER BY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
LIMIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
OFFSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
FOR VIEW and FOR REFERENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
FOR UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
SOQL SELECT Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
SOQL SELECT Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
convertCurrency() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
convertTimezone() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
FORMAT () . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
GROUPING(fieldName) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
toLabel() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Relationship Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Understanding Relationship Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Using Relationship Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Understanding Relationship Names, Custom Objects, and Custom Fields . . . . . . . . . . . 66
Understanding Query Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
null Values in Lookup Relationships and Outer Joins . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Identifying Parent and Child Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Understanding Relationship Fields and Polymorphic Fields . . . . . . . . . . . . . . . . . . . . . 72
Understanding Relationship Query Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
![](https://csdnimg.cn/release/download_crawler_static/89355330/bg4.jpg)
Using Relationship Queries with History Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Using Relationship Queries with Data Category Selection Objects . . . . . . . . . . . . . . . . . 78
Using Relationship Queries with the Partner WSDL . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Change the Batch Size in Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
SOQL Limits on Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
SOQL with Big Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Syndication Feed SOQL and Mapping Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Location-Based SOQL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Chapter 3: Salesforce Object Search Language (SOSL) . . . . . . . . . . . . . . . . . . . . . . . . 90
Typographical Conventions in This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
SOSL Limits on Search Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
SOSL Limits on External Object Search Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
SOSL Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Example Text Searches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
convertCurrency() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
FIND {SearchQuery} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
FORMAT() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
IN SearchGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
LIMIT n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
OFFSET n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
ORDER BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
RETURNING FieldSpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
toLabel(fields) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Update an Article’s Keyword Tracking with SOSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Update an Article’s Viewstat with SOSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
USING Listview= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
WHERE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
WITH DATA CATEGORY DataCategorySpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
WITH DivisionFilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
WITH HIGHLIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
WITH METADATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
WITH NETWORK NetworkIdSpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
WITH PricebookId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
WITH SNIPPET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
WITH SPELL_CORRECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Contents
![](https://csdnimg.cn/release/download_crawler_static/89355330/bg5.jpg)
CHAPTER 1 Introduction to SOQL and SOSL
If you’ve built a custom UI for Salesforce, you can use the Salesforce Object Query Language (SOQL) and
Salesforce Object Search Language (SOSL) APIs to search your organization’s Salesforce data.
This guide explains when to use SOQL and SOSL and outlines the syntax, clauses, limits, and performance
considerations for both languages. It is intended for developers and assumes knowledge and experience
working with APIs to interact with data.
Deciding Which to Use
A SOQL query is the equivalent of a SELECT SQL statement and searches the org database. SOSL is a
programmatic way of performing a text-based search against the search index.
Whether you use SOQL or SOSL depends on whether you know which objects or fields you want to
search, plus other considerations.
Use SOQL when you know which objects the data resides in, and you want to:
•
Retrieve data from a single object or from multiple objects that are related to one another.
•
Count the number of records that meet specified criteria.
•
Sort results as part of the query.
•
Retrieve data from number, date, or checkbox fields.
Use SOSL when you don’t know which object or field the data resides in, and you want to:
•
Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize
multiple terms within a field and build a search index from this, SOSL searches are faster and can
return more relevant results.
•
Retrieve multiple objects and fields efficiently where the objects might or might not be related to
one another.
•
Retrieve data for a particular division in an organization using the divisions feature.
•
Retrieve data that’s in Chinese, Japanese, Korean, or Thai. Morphological tokenization for CJKT terms
helps ensure accurate results.
Note: SOSL doesn’t support big objects.
Performance Considerations
To increase the efficiency of queries and searches, keep in mind:
•
Both SOQL WHERE filters and SOSL search queries can specify text you should look for. When a
given search can use either language, SOSL is generally faster than SOQL if the search expression
uses a CONTAINS term.
•
SOSL can tokenize multiple terms within a field (for example, multiple words separated by spaces)
and builds a search index off this. If you’re searching for a specific distinct term that you know exists
within a field, you might find SOSL is faster than SOQL for these searches. For example, you might
1
剩余127页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_30777913
- 粉丝: 297
- 资源: 78
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)