The field formula is an expression that returns a single value. A
value can be of various types: number, real, boolean, string, date,
date only, time only. It can also be the built-in constant value null
to represent an empty field value.
When applying operators on two values of different type one value is converted into a compatible type, e.g. "Label " + 123
results in the string "Label 123"
because the second value is convertted to string type before applying the operator.
In case of an error the field value is set according to the user's settings. Otherwise the resulting value is automatically converted to the type of the corresponding field to set the value.
The arithmetic operators are a subset of the ones already known from programming languages such as C, Java, or JavaScript.
Expressions can be separated by comma to evaluate to the last expression of this sequence the same way as in C, Java, or JavaScript. This is useful for preceding the actual expression returning the formula value with function call expressions that set variable values.
<expression> ::= <conditional expression> <conditional expression> ::= <conditional or expression> | <conditional or expression> ? <expression> : <conditional expression> <conditional or expression> ::= <conditional and expression> | <conditional or expression> || <conditional and expression> <conditional and expression> ::= <equality expression> | <conditional and expression> && <equality expression> <equality expression> ::= <relational expression> | <equality expression> == <relational expression> | <equality expression> != <relational expression> <relational expression> ::= <additive expression> | <relational expression> < <additive expression> | <relational expression> > <additive expression> | <relational expression> <= <additive expression> | <relational expression> >= <additive expression> <additive expression> ::= <multiplicative expression> | <additive expression> + <multiplicative expression> | <additive expression> - <multiplicative expression> <multiplicative expression> ::= <unary expression> | <multiplicative expression> * <unary expression> | <multiplicative expression> / <unary expression> | <multiplicative expression> % <unary expression> <unary expression> ::= + <unary expression> | - <unary expression> | <primary> <primary> ::= <literal> | ( <expression> ) | <function invocation> <function invocation> ::= <function name> ( <argument list>? ) <argument list> ::= <expression> | <argument list> , <expression>
itembyindex()
or - for better readability - itemByIndex()
min()
for another usage of this function to aggregate field values of sub-table items. min(fieldValue("Image Width"), fieldValue("Image Height"))
returns the length of the smaller dimension of the image size.max()
for another usage of this function to aggregate field values of sub-table items. max(fieldValue("Image Width"), fieldValue("Image Height"))
returns the length of the larger dimension of the image size. max(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Download"), "Date")
returns the date of the last time this asset was downloaded.sum()
for another usage of this function to aggregate field values of sub-table items.null
if it is not yet set. var("notes", fieldValue("Notes")), var("status", fieldValue("Status", true)), var("notes") + "\n" + var("status")
sets two variables before using their values for the formula. var("status", fieldValue("Status")), var("status") == 1 ? "open" : var("status") == 2 ? "closed" : "unknown"
sets a variable before using it multiple times.
var("comments", subTableItems("AssetRecords/{04a4080f-fec0-4e01-822f-b9125c0b5ac9}")), count(var("comments")) == 0 ? "no comment" : "number of comments: " + count(var("comments"))
sets a variable before using it multiple times.
integer(12.3456)
returns the integer value 12.
string(1234, "%8d")
returns " 1234"
string(1.2345678, "%8.2f")
returns " 1.23"
YYYY
the year in 4 digits YY
the year in 2 digits MM
the month in 2 digits M
the month in 1 or 2 digits DD
the day in 2 digits D
the day in 1 or 2 digits hh
the hour in 2 digits h
the hour in 1 or 2 digits mm
the minute in 2 digits m
the minute in 1 or 2 digits ss
the second in 2 digits s
the second in 1 or 2 digits AM/PM
use 12 hour conversion adding "AM" or "PM" as appropriate am/pm
use 12 hour conversion adding "am" or "pm" as appropriate string(now(), "MM/DD/YYYY hh:mm:ss AM/PM")
could convert to "04/17/2007 07:25:34 AM"
subString(fieldValue("Record Name"), 1)
returns the field value of the given field starting with the second character.
indexOf(fieldValue("Version History"), "Final") != -1 ? 1 : 0
returns a value of 1
if the record name contains the string "Final"
. Otherwise it returns the value 0
.
lastIndexOf(fieldValue("Asset Name"), ".") != -1 ? subString(fieldValue("Asset Name"), lastIndexOf(fieldValue("Asset Name"), ".") + 1) : ""
returns the file name extension of the asset (without the period).
string
every occurrence of oldstring
is replaced by the given newstring
.oldstring
is contained in newstring
is handled correctly.
"YYYY-MM-DD hh:mm:ss"where
YYYY
is the year given in four digitsMM
is the month given in two digits (01..12)DD
is the day of month given in two digits (01..31)hh
is the hour given in two digits of a 24-hour-clock (00..23)mm
are the minutes given in two digits (00..59)ss
are the seconds given in two digits (00..59). date("2006-08-24 17:34:12")
startOfYear () + years (1)
returns the date value representing 1st of January of next year 00:00:00.
now() - seconds(30)
returns a date value representing 30 seconds back from now.
now() - minutes(30)
returns a date value representing 30 minutes back from now.
now() - hours(6)
returns a date value representing 6 hours back from now.
now() - days(2)
returns a date value representing 2 days back from now.
now() - weeks(1)
returns a date value representing 1 week back from now.
now() - months(6)
returns a date value representing 6 months back from now.
now() - years(1)
returns a date value representing 1 year back from now.
YYYY-MM-DD
whereYYYY
is the year given in four digits (e.g. 2006)MM
is the month given in 1 or two digits
(e.g. 12). If the given month is 0 the DateOnly value is interpreted as
the whole given year.DD
is the day of moth given in one or
two digits (e.g. 1). If the given day is 0 the DateOnly value is
interpreted as the whole given month or year. dateOnly("2006-12-22") + dateOnly("0-1-0")
will result in the DateOnly value 2007-01-22 dateOnly("2006-12-22") + 100
will result in the DateOnly value 2007-04-01.
min()
, max()
, sum()
, average()
, median()
, or count()
.
table_name
specifies the name of the sub-table to use.query
to find the items you want to work on. An empty string finds all items that depend on the current item where the formula is defined.sort_field_list
is a string that contains the fields to sort the collection by, separated by comma. Passing an empty string does not sort the collection.sort_directions_list
is also a string that contains the sort directions for each of the fields specified in sort_field_list
. You can specify a list of "ascending" or "descending" separated by comma. The default is "ascending".startIndex
returns a collection that starts at the given offset. The default is 0 which starts at the beginning.count
returns a collection that only contains a number of items up to the given limit. The default is not to limit the number of items. fieldValue("User", itemByIndex(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Download", "Date", "descending"), 0))
returns the user ID of the user who downloaded this asset last. count(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == 'Check Out'"))
returns the number of checkout operations performed with this asset.subTableItems()
function to get a collection of items to process.field_specifier
parameter determines the field to process. It uses the same syntax as described in the fieldValue()
function.min()
for another usage of this function to determine the minimum of values given directly as parameters. min(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Preview"), "Date")
returns the first date that this asset was previewed.subTableItems()
function to get a collection of items to process.field_specifier
parameter determines the field to process. It uses the same syntax as described in the fieldValue()
function.max()
for another usage of this function to determine the maximum of values given directly as parameters. max(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Download"), "Date")
returns the date of the last time this asset was downloaded.subTableItems()
function to get a collection of items to process.field_specifier
parameter determines the field to process. It uses the same syntax as described in the fieldValue()
function.separator
parameter allows to specify a separator to be automatically inserted between two string values.sum()
for another usage of this function to determine the sum of values given directly as parameters. sum(subTableItems("AssetRecords/{aceea098-8984-4e07-8868-417ccddeaddf}"), "Price")
may calculate the sum amount earned by selling this asset (assuming the sub-table exists and has the corresponding values).subTableItems()
function to get a collection of items to process.field_specifier
parameter determines the field to process. It uses the same syntax as described in the fieldValue()
function. average(subTableItems("AssetRecords/{aceea098-8984-4e07-8868-417ccddeaddf}"), "Price")
may calculate the average amount earned by selling this asset (assuming the sub-table exists and has the corresponding values).subTableItems()
function to get a collection of items to process.field_specifier
parameter determines the field to process. It uses the same syntax as described in the fieldValue()
function.subTableItems()
function to get a collection of items to process.
count(subTableItems("AssetRecords/{04a4080f-fec0-4e01-822f-b9125c0b5ac9}"))
returns the number of comments made to this asset.collection
object is returned by the subTableItems()
function. fieldValue("User", itemByIndex(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Download", "Date", "descending"), 0))
returns the user ID of the user who downloaded this asset last.null
field_specifier
parameter determines the field. It uses the same syntax as described in the fieldValue()
function.itemByIndex()
function to get an item out of a collection.fieldValue()
for another usage of this function to get a field value for the current item or an item in a super table of the current item. fieldValue("User", itemByIndex(subTableItems("AssetRecords/{a89b908c-e98e-413b-ac4d-50668b2fafbc}", "'{40f05fd7-9647-4662-a589-7b2be4034f12}:Asset Usage' == Download", "Date", "descending"), 0))
returns the user ID of the user who downloaded this asset last.field_specifier
parameter uses the syntax defined in the fieldValue()
function.itemByIndex()
function to get an item out of a collection.fieldHasValue()
for another usage of this function to check for a field value for the current item or an item in a super table of the current item.null
field_specifier
parameter can be one of the following:"Record Name"
)."{af4b2e00-5f6a-11d2-8f20-0000c0e166dc}"
)."{af4b2e00-5f6a-11d2-8f20-0000c0e166dc}:Record Name"
.1382239853
or 0x52634e6d
)"AssetRecords/Record Name"
or "AssetRecords:Record Name"
)."AssetRecords"
table's host item from a formula field in the "Asset Usage History"
table to store asset record field values in "Asset Usage"
items.as_string
to be true
and returns the assigned categories of the record. Each category is returned as the complete path (e.g. "Top Level:Next Level:The Assigned Category") with a "\n" character at the end.
A ":" in the category name is escaped using "::" to make it differ from the path separator.
You can check whether a record has a specific category assigned by using indexOf(fieldValue("Categories"), "Top Level:Next Level:The Assigned Category\n") == -1 ? "Not assigned" : "assigned"
item
as a parameter. This is returned by the itemByIndex()
.as_string
parameter is a boolean specifying whether the field value should be converted into a string when returned.fieldValue()
for another usage of this function to get a field value for an item of a collection created for a sub-table. fieldValue("Record Name")
returns the record name. fieldValue("{af4b2e00-5f6a-11d2-8f20-0000c0e166dc}")
also returns the record name. fieldValue("{af4b2e00-5f6a-11d2-8f20-0000c0e166dc}:Record Name")
also returns the record name. fieldValue("Color Mode")
returns the value of the "Color Mode" field (e.g. 1
). fieldValue("Color Mode", true)
returns the value of the "Color Mode" field in a localized string (e.g. "Grayscale"
). fieldValue("AssetRecords/{af4b2e07-5f6a-11d2-8f20-0000c0e166dc}:Status", true)
can be used in a field of the "Asset Usage History"
. It returns the value of the "Status" field of the host item in a localized string (e.g. "Approved"
).
null
as_string
parameter is a boolean specifying whether the field value should be converted into a string when returned.field_specifier
parameter can be one of the following:"Last Name"
)"{7c43714f-daa4-11d6-b6be-0050baeba6c7}"
for the user's e-mail address) userFieldValue("Last Name")
returns the last name of the current user. userFieldValue("{7c43714f-daa4-11d6-b6be-0050baeba6c7}")
returns the e-mail address of the current user.
field_specifier
parameter uses the syntax defined in the fieldValue()
function.field_specifier
parameter uses the syntax defined in the userFieldValue()
function.