Math Operators
| OPERATOR | DESCRIPTION |
|---|---|
| +(添加) | 计算两个值的总和。 |
| - (减去) | 计算两个值的差值。 |
| *(乘) | 计算乘法。 |
| /(除) | 计算除法。 |
| ^(求幂) | 将数字运算到指定数字的幂。 |
| ()(左括号和右括号) | 指定首先计算左括号和右括号内的表达式。所有其他表达式都使用标准运算符优先级进行计算。 |
Logical Operators
| OPERATOR | DESCRIPTION |
|---|---|
| = 和 ==(相等) | 评估两个值是否相等。= 和 == 运算符可以互换。 |
| <> 和 !=(不相等) | 评估两个值是否不相等。 |
| <(小于) | 评估某个值是否小于此符号后面的值。 |
| >(大于) | 评估某个值是否大于此符号后面的值。 |
| <=(小于或等于) | 评估某个值是否小于或等于此符号后面的值。 |
| >=(大于或等于) | 评估某个值是否大于或等于此符号后面的值。 |
| && (和) | 评估两个值或表达式是否都为真。将此运算符用作逻辑函数 AND 的替代方法。 |
| || (或者) | 评估多个值或表达式中的至少一个是否为真。将此运算符用作逻辑函数 OR 的替代方法。 |
Text Operators
| OPERATOR | DESCRIPTION |
|---|---|
| &(连接) | 连接两个或多个字符串。 |
Date and Time Functions
| FUNCTION | DESCRIPTION |
|---|---|
| ADDMONTHS | 返回指定日期之前或之后指定月数的日期。如果指定的日期是该月的最后一天,则结果日期是结果月份的最后一天。否则,结果具有与指定日期相同的日期组件。 Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date. |
| DATE | 根据您输入的年、月和日值返回日期值。如果公式字段中 DATE 函数的值是无效日期,例如非闰年的 2 月 29 日,Salesforce 会在详细信息页面上显示错误。 Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year. |
| DATEVALUE | 返回日期/时间或文本表达式的日期值。 Returns a date value for a date/time or text expression. |
| DATETIMEVALUE | 返回年、月、日和 GMT 时间值。 Returns a year, month, day, and GMT time value. |
| DAY | 以 1 到 31 之间的数字形式返回一个月中的某一天。 Returns a day of the month in the form of a number between 1 and 31. |
| HOUR | 以 1 到 24 的数字形式返回不带日期的当地时间小时值。 Returns the local time hour value without the date in the form of a number from 1 through 24. |
| MILLISECOND | 以从 0 到 999 的数字形式返回毫秒值。 Returns a milliseconds value in the form of a number from 0 through 999. |
| MINUTE | 以从 0 到 60 的数字形式返回分钟值。 Returns a minute value in the form of a number from 0 through 60. |
| MONTH | 以给定日期的数字格式返回月份,一个介于 1(一月)和 12(十二月)之间的数字。 Returns the month, a number between 1 (January) and 12 (December) in number format of a given date. |
| NOW | 返回表示当前时刻的日期/时间。 Returns a date/time representing the current moment. |
| SECOND | 以 0 到 60 之间的数字形式返回秒值。 Returns a seconds value in the form of a number from 0 through 60. |
| TIMENOW | 返回代表当前时刻的 GMT 时间值。如果您只想跟踪时间而不是日期,请使用此函数而不是 NOW 函数。 Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date. |
| TIMEVALUE | 返回不带日期的本地时间值,例如营业时间。 Returns the local time value without the date, such as business hours. |
| TODAY | 将当前日期作为日期数据类型返回。 Returns the current date as a date data type. |
| WEEKDAY | 返回给定日期的星期几,周日使用 1,周一使用 2,周六使用 7。 Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday. |
| YEAR | 以数字格式返回给定日期的四位数年份。 Returns the four-digit year in number format of a given date. |
Logical Functions
| FUNCTION | DESCRIPTION |
|---|---|
| AND | 如果所有值都为真,则返回 TRUE 响应;如果一个或多个值为假,则返回 FALSE 响应。 Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. |
| BLANKVALUE | 确定表达式是否有值,如果没有则返回替代表达式。如果表达式有值,则返回表达式的值。 Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression. |
| CASE | 根据一系列值检查给定表达式。如果表达式等于一个值,则返回相应的结果。如果它不等于任何值,则返回else_result. Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn’t equal to any values, it returns the else_result. |
| IF | 确定表达式是真还是假。如果为真则返回给定值,如果为假则返回另一个值。 Determines if expressions are true or false. Returns a given value if true and another value if false. |
| ISBLANK | 确定表达式是否有值,如果没有则返回 TRUE。如果它包含一个值,则此函数返回 FALSE。 Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE. |
| ISCLONE | 检查记录是否是另一条记录的克隆,如果一项是克隆,则返回 TRUE。否则,返回 FALSE。 Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE. |
| ISNEW | 检查公式在创建新记录期间是否正在运行,如果是,则返回 TRUE。如果正在更新现有记录,则此函数返回 FALSE。 Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE. |
| ISNULL | 确定表达式是否为空(空白),如果是则返回 TRUE。如果它包含一个值,则此函数返回 FALSE。 Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE. 重要在新公式中使用 ISBLANK 而不是 ISNULL。ISBLANK 具有与 ISNULL 相同的功能,但也支持文本字段。Salesforce 将继续支持 ISNULL,因此您无需更改任何现有公式。 IMPORTANT Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. |
| ISNUMBER | 确定文本值是否为数字,如果是则返回 TRUE。否则,它返回 FALSE。 Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE. |
| NOT | 为 TRUE 返回 FALSE,为 FALSE 返回 TRUE。 Returns FALSE for TRUE and TRUE for FALSE. |
| NULLVALUE | 确定表达式是否为空(空白),如果是,则返回替代表达式。如果表达式不为空,则返回表达式的值。 Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression. 重要提示在新公式中使用 BLANKVALUE 而不是 NULLVALUE。BLANKVALUE 具有与 NULLVALUE 相同的功能,但也支持文本字段。Salesforce 继续支持 NULLVALUE,因此您无需更改现有公式。 IMPORTANT Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. |
| OR | 确定表达式是真还是假。如果任何表达式为真,则返回 TRUE。如果所有表达式都为假,则返回 FALSE。 Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. |
| PRIORVALUE | 返回字段的前一个值。 Returns the previous value of a field. |
Math Functions
| FUNCTION | DESCRIPTION |
|---|---|
| ABS | 计算一个数的绝对值。数字的绝对值是没有正号或负号的数字。 Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. |
| CEILING | 将数字向上舍入为最接近的整数,如果为负,则远离零。 Rounds a number up to the nearest integer, away from zero if negative. |
| DISTANCE | 以英里或公里为单位计算两个位置之间的距离。 Calculates the distance between two locations in miles or kilometers. |
| EXP | 返回 e 的值,该值是您指定的数字的幂。 Returns a value for e raised to the power of a number you specify. |
| FLOOR | 返回一个向下舍入到最接近的整数的数字,如果为负则返回零。 Returns a number rounded down to the nearest integer, towards zero if negative. |
| GEOLOCATION | 根据提供的纬度和经度返回地理位置。必须与 DISTANCE 函数一起使用。 Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function. |
| LN | 返回指定数字的自然对数。自然对数基于常数 e 值 2.71828182845904。 Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904. |
| LOG | 返回一个数字的以 10 为底的对数。 Returns the base 10 logarithm of a number. |
| MAX | 返回数字列表中的最大数字。 Returns the highest number from a list of numbers. |
| MCEILING | 将数字向上舍入为最接近的整数,如果为负则向零舍入。 Rounds a number up to the nearest integer, towards zero if negative. |
| MFLOOR | 将数字向下舍入到最接近的整数,如果为负,则远离零。 Rounds a number down to the nearest integer, away from zero if negative. |
| MIN | 返回数字列表中最小的数字。 Returns the lowest number from a list of numbers. |
| MOD | 返回一个数除以指定的除数后的余数。 Returns a remainder after a number is divided by a specified divisor. |
| ROUND | 返回与您指定的数字最接近的数字,通过指定的位数限制新数字。 Returns the nearest number to a number you specify, constraining the new number by a specified number of digits. |
| SQRT | 返回给定数字的正平方根。 Returns the positive square root of a given number. |
Text Functions
| FUNCTION | DESCRIPTION |
|---|---|
| BEGINS | 确定文本是否以特定字符开头,如果是则返回 TRUE。如果不是,则返回 FALSE。 Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn’t. |
| BR | 在文本字符串中插入换行符。 Inserts a line break in a string of text. |
| CASESAFEID | 将 15 个字符的 ID 转换为不区分大小写的 18 个字符的 ID。 Converts a 15-character ID to a case-insensitive 18-character ID. |
| CONTAINS | 比较文本的两个参数,如果第一个参数包含第二个参数,则返回 TRUE。如果不是,则返回 FALSE。 Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE. |
| FIND | 返回字符串在以数字表示的文本字符串中的位置。 Returns the position of a string within a string of text represented as a number. |
| GETSESSIONID | 返回用户的会话 ID。 Returns the user’s session ID. |
| HTMLENCODE | 通过将 HTML 中保留的字符(例如大于号 (>))替换为 HTML 实体等效项(例如>.Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >. |
| HYPERLINK | 创建指向可从指定文本链接的指定 URL 的链接。Creates a link to a URL specified that is linkable from the text specified. |
| IMAGE | 插入带有替代文本和高度和宽度规格的图像。Inserts an image with alternate text and height and width specifications. |
| INCLUDES | 确定在多选选项列表字段中选择的任何值是否等于您指定的文本文字。Determines if any value selected in a multi-select picklist field equals a text literal you specify. |
| ISPICKVAL | 确定选项列表字段的值是否等于您指定的文本文字。Determines if the value of a picklist field is equal to a text literal you specify. |
| JSENCODE | 通过在不安全的 JavaScript 字符(例如撇号 (‘) 之前)插入转义字符(例如反斜杠 ()),对用于 JavaScript 的文本和合并字段值进行编码。 Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (), before unsafe JavaScript characters, such as the apostrophe (’). |
| JSINHTMLENCODE | 通过将 HTML 中保留的字符替换为 HTML 实体等效项并在不安全的 JavaScript 字符之前插入转义字符,对 HTML 标记内的 JavaScript 中使用的文本和合并字段值进行编码。是等价于的便利函数。也就是说, 首先用 对someValue进行编码 ,然后用 对结果进行编码。JSINHTMLENCODE(someValue) JSENCODE(HTMLENCODE((someValue)) JSINHTMLENCODE HTMLENCODE JSENCODEEncodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE. |
| LEFT | 从文本字符串的开头返回指定数量的字符。 Returns the specified number of characters from the beginning of a text string. |
| LEN | 返回指定文本字符串中的字符数。 Returns the number of characters in a specified text string. |
| LOWER | 将指定文本字符串中的所有字母转换为小写。任何不是字母的字符都不受此函数的影响。如果提供了语言环境,则应用语言环境规则。 Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. |
| LPAD | 将您指定的字符插入到文本字符串的左侧。 Inserts characters you specify to the left-side of a text string. |
| MID | 从给定起始位置的文本字符串的中间返回指定数量的字符。 Returns the specified number of characters from the middle of a text string given the starting position. |
| RIGHT | 从文本字符串的末尾返回指定数量的字符。 Returns the specified number of characters from the end of a text string. |
| RPAD | 将您指定的字符插入到文本字符串的右侧。 Inserts characters that you specify to the right-side of a text string. |
| SUBSTITUTE | 用新文本替换文本字符串中的旧文本。 Substitutes new text for old text in a text string. |
| TEXT | 在任何使用公式的地方将百分比、数字、日期、日期/时间或货币类型字段转换为文本。此外,将选项列表值转换为批准规则、批准步骤规则、工作流规则、升级规则、分配规则、自动响应规则、验证规则、公式字段、字段更新以及自定义按钮和链接中的文本。 Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links. |
| TRIM | 从文本字符串的开头和结尾删除空格和制表符。 Removes the spaces and tabs from the beginning and end of a text string. |
| UPPER | 将指定文本字符串中的所有字母转换为大写。任何不是字母的字符都不受此函数的影响。如果提供了语言环境,则应用语言环境规则。 Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. |
| URLENCODE | 通过将 URL 中的非法字符(例如空格)替换为表示RFC 3986,统一资源标识符 (URI):通用语法中定义的那些字符的代码,对 URL 中使用的文本和合并字段值进行编码。例如,空格替换为%20,感叹号替换为%21。Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21. |
| VALUE | 将文本字符串转换为数字。 Converts a text string to a number. |
Summary Functions
The following functions are available with summary, matrix, and joined reports.
| FUNCTION | DESCRIPTION |
|---|---|
| PARENTGROUPVAL | 此函数返回指定父分组的值。“父”分组是包含公式的分组之上的任何级别。您只能在自定义汇总公式和报表分组级别使用此函数,但不能在汇总级别使用。 This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. |
| PREVGROUPVAL | 此函数返回指定的先前分组的值。“上一个”分组是报告中当前分组之前的分组。选择分组级别和增量。增量是当前摘要之前的列数或行数。默认为 1;最大值为 12。您只能在自定义汇总公式和报表分组级别使用此函数,但不能在汇总级别使用。 This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. |
Advanced Functions
| FUNCTION | DESCRIPTION |
|---|---|
| CURRENCYRATE | 返回给定货币 ISO 代码的公司货币的兑换率。如果货币无效,则返回 1.0。 Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0. |
| GETRECORDIDS | 以记录 ID 的形式返回列表中选定记录的字符串数组,例如列表视图或相关列表。 Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list. |
| IMAGEPROXYURL | 安全地检索外部图像并防止未经授权的用户凭据请求。 Securely retrieves external images and prevents unauthorized requests for user credentials. |
| INCLUDE | 从 s-control 片段返回内容。使用此函数可重用许多 S-Control 中的公共代码。Returns content from an s-control snippet. Use this function to reuse common code in many s-controls. |
| ISCHANGED | 将字段的值与前一个值进行比较,如果值不同则返回 TRUE。如果值相同,则此函数返回 FALSE。 Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE. |
| JUNCTIONIDLIST | 根据提供的 ID 返回一个 JunctionIDList。Returns a JunctionIDList based on the provided IDs. |
| LINKTO | 以链接(href 和锚标记)的形式返回自定义 s-control 或 Salesforce 页面的相对 URL。Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page. |
| PREDICT | 根据指定的记录 ID 或字段列表及其值返回对记录的 Einstein Discovery 预测。Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values. |
| REGEX | 将文本字段与正则表达式进行比较,如果匹配则返回 TRUE。否则,它返回 FALSE。正则表达式是一个字符串,用于根据一定的语法规则描述字符串的格式。 Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules. |
| REQUIRESCRIPT | 为您指定的 URL 返回带有源的脚本标记。在引用 Lightning 平台 AJAX 工具包或其他 JavaScript 工具包时使用此函数。 Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits. |
| URLFOR | 返回操作、s-control、Visualforce 页面或 Visualforce 页面中静态资源存档中的文件的相对 URL。 Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page. |
| VLOOKUP | 通过在类似于 VLOOKUP() Excel 函数的自定义对象上查找相关值来返回值。Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. |
重要在新公式中使用 ISBLANK 而不是 ISNULL。ISBLANK 具有与 ISNULL 相同的功能,但也支持文本字段。Salesforce 将继续支持 ISNULL,因此您无需更改任何现有公式。