Javascript Formulas
GridMate provides a lightweight javascript syntax to define calculated columns on the browser side. The formulas are calculated when a grid rendered to the end user or a field is updated.
Data Types
Currently the javascript engine supports the following data types as a return value:
Text
Checkbox
Date
Number
Currency
Percent
RichText
Note that the data type is also used to customize the display for the user
Operators
Currently the following operators are supported:
+:(plus)
-:(minus)
*:(multiply)
/:(divide)
%:(Modulus)
<:(less than)
>::(greater than)
<=:(less or equal)
>=:(greater or equal)
&&:(and)
||:(or)
==:(equal)
!=:(not equal)
Functions
Math Functions
CEILING(number) : rounds up and returns the smallest integer greater than or equal to a given number.
EXP(number) : returns e raised to the power of a number.
FLOOR(number) : rounds down and returns the largest integer less than or equal to a given number.
LN(number) : returns the natural logarithm (base e) of a number.
LOG(number) : returns the base 10 logarithm of a number.
MAX(number, number) : returns the largest of the numbers given as input parameters.
MIN(number, number) : returns the smallest of the numbers given as input parameters.
ROUND(number, num_digits) : returns the value of a number rounded to the nearest integer.
SQRT(number) : returns the square root of a number.
Text Functions
BEGINS(text, compare_text) : determines if text begins with specific characters.
CONCAT(text1, text2) : concats two arguments of text and returns the concatenated text.
CONTAINS(text, compare_text) : compares two arguments of text and returns true if the first argument contains the second argument.
LEFT(text, num_chars) : returns the specified number of characters from the beginning of a text string.
LEN(text) : returns the number of characters in a specified text string.
LOWER(text) : converts all letters in the specified text string to lowercase.
LPAD(text, padded_length, pad_string) : inserts characters you specify to the left-side of a text string.
MID(text, start_num, num_chars) : returns the specified number of characters from the middle of a text string given the starting position.
RIGHT(text, num_chars) : returns the specified number of characters from the end of a text string.
RPAD(text, padded_length, pad_string) : inserts characters that you specify to the right-side of a text string.
SUBSTITUTE(text, old_text, new_text) : substitutes new text for old text in a text string
TRIM(text) : removes the spaces and tabs from the beginning and end of a text string.
UPPER(text) : converts all letters in the specified text string to uppercase.
Logical Functions
ISNULL(expression) : determines if an expression is null.
NOT(logical) : returns the inverse of the given expression.
OR(logical1, logical2) : determines if expressions are true or false. Returns true if any expression is true.
AND(logical1, logical2) : returns a true response if all values are true.
IF(logical_test, value_if_true, value_if_false) : determines if expressions are true or false. Returns a given value if true and another value if false.
CASE(expression, βvalue1, result1, ...) : checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result.
Date Functions
DATEADD(date, amount, unit): Adds a specified time value to a date.
DATEDIFF(start, end, unit) : Returns the difference between two dates.
DATEVALUE(expression) : Returns a date value for a given text expression.
MINUTE(date) : Returns a minute value in the form of a number.
HOUR(date) : Returns the hour value in the form of a number.
DAY(date) : Returns a day of the month in the form of a number.
WEEKDAY(date) : Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday
MONTH(date) : Returns the month, a number from 1 (January) through 12 (December) in number format of a given date
YEAR(date) : Returns a year of the date in the form of a number
TODAY() : Returns the current date as a date data type
NOW() : Returns a date/time representing the current moment
Unit can be "minute", "hour", "day", "month" or "year".
Other Functions
APEX(handler, param1, value1, ...) : Call an Apex class and return its value.
Last updated