Widget Building Function Reference#
The following table describes which functions can be applied at each widget builder stage. For more on how to use functions to set up widgets, see Advanced Setup - Widgets
const : Evaluates whether the field value matches the argument.
convert : Converts a value to a specified type.
Example Expression
convert(GOAL_HOURS,“int”)Example Input
Result
dateFixed : Returns all records that have the specified date in the specified date field.
Works the same way as the Fixed date parameter option in Widget Properties. For more info, see Editing a Date Parameter - Advanced .
dateFixedRange : Returns all records that have in the specified date field a date that’s between the ‘from’ date and the ‘to’ date (inclusive).
Works the same way as the Fixed date parameter option in Widget Properties. For more info, see Editing a Date Parameter - Advanced .
dateRelative : Returns all records that have in the specified date field a date that is in the dynamic date range (inclusive) counting back from today’s date.
The second argument is the number of days counting back from today’s date to get the start date and the third argument is the number of days counting back from today’s date to get the end date. Works the same way as the Days date parameter option in Widget Properties. For more info, see Editing a Date Parameter - Advanced . In the example, the dynamic date range is calculated based on May 2nd, 2023 at 12:00 AM as the current date and time.
dateRelativeRange : Returns all records that have in the specified date field a date that’s within the dynamic date range that’s’based on today’s date.
If you specify a weekly range, you have to specify in the third argument which day of the week should be considered the first day of the week.Works the same way as the Relative date parameter option in Widget Properties. For more info, see Editing a Date Parameter - Advanced. In the example, the dynamic date range is calculated based on May 2nd, 2023 at 10:00 AM as the current date and time.
exists : When set to ‘true’, returns records that have the specified field even when it has only null values. If set to ‘false’, returns only records that don’t have the field.
regexp : Lets you select records that have a field value that matches a pattern specified as a regular expression : FIELDNAME = regexp(expression(YOUR_REGEX_EXPRESSION), options(ADVANCED_REGEX_OPTIONS).
For more information, see Selecting Records based on Patterns in String Values.
sysdate : Returns the system date in Coordinated Universal Time (UTC) i.e., Greenwich Mean Time.
For more info, see Building Widgets that Refer to the System Date. In the example, the function is run on April 19th, 2023.
sysdatetz : Returns the system date in the WMS’s local time zone.
For more info, see Building Widgets that Refer to the System Date. In the example, the function is run on April 19th, 2023.
absolute : Returns the absolute value of a number.
add : Adds numbers together or adds numbers and a date.
and : Evaluates one or more expression s and returns true if all of the expression s are true or if evoked with no argument expression s. Otherwise, $and returns false.
average : Returns the average value of the numeric values.
ceil : Returns the smallest integer greater than or equal to the specified number.
compare : Compares two values and returns: ‘-1’ if the first value is less than the second; ‘1’ if the first value is greater than the second; and ‘0’ if the two values are equivalent.
condition : Evaluates a boolean expression to return one of the two specified return expression s.
dateDifferenceInMs : Subtracts two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date.
dateToString : Converts a date object to a string according to a user-specified format.
Function format: dateToString(DATE_FIELD, “OUTPUT FORMAT”, timezone[optional], value to return if date is null or missing.) The output format “%Y-%m-%dT%H:%M:%S.%LZ” contains the maximum number of elements that can be included. You can ommit elements in reverse order to create a simpler format. For example,”%Y-%m-%d” would format the date with only the year, month, and day.
dayOfMonth : Returns the day of the month for a date as a number between 1 and 31.
dayOfWeek : Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
dayOfYear : Returns the day of the year for a date as a number between 1 and 366.
divide : Divides one number by another and returns the result.
equals : Compares two values and returns: ‘true’ when the values are equivalent. Otherwise, ‘false’.
exp : Raises Eulers number (i.e. e ) to the specified exponent and returns the result.
fieldType : Returns the data type (e.g, ‘string’ or ‘int’) of the field you enter as an argument.
findSubstring : Searches a string for a substring and returns the index (zero-based) of the first instance. If the substring is not found, returns -1.
floor : Returns the largest integer less than or equal to the specified number.
getElementFromArray : Returns the element at the specified array index.
greaterThan : Compares two values and returns: ‘true’ when the first value is greater than the second value, and ‘false’ when the first value is less than or equivalent to the second value.
greaterThanOrEqual : Compares two values and returns ‘true’ when the first value is greater than or equal to the second value. Otherwise it returns false.
hour : Returns the hour portion of a date as a number between 0 and 23.
in : Returns TRUE if the record’s specified field has any of the values enclosed in the square brackets.
isNull : Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.
If the expression evaluates to a null value, including instances of undefined values or missing fields, returns the value of the replacement expression.
isoDayOfWeek : Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).
isoWeek : Returns the week number in ISO 8601 format, ranging from 1 to 53.
isoWeekYear : Returns the year number in ISO 8601 format.
lessThan : Compares two values and returns ‘true’ when the first value is less than the second value. Otherwise it returns false.
lessThanOrEqual : Compares two values and returns ‘true’ when the first value is less than or equal to the second value. Otherwise it returns false.
literal : Returns the specified value.
ln : Calculates the natural logarithm ln (i.e log e) of a number and returns the result as a double.
log : Calculates the log of a number in the specified base and returns the result as a double.
log10 : Calculates the log base 10 of a number and returns the result as a double.
lowerCase : Converts a string to lowercase, returning the result.
max : Returns the maximum value from the argument s.
millisecond : Returns the millisecond portion of a date as an integer between 0 and 999.
min : Returns the minimum value from the argument s.
minute : Returns the minute portion of a date as a number between 0 and 59.
modulus : Divides one number by another and returns the remainder.
month : Returns the month of a date as a number between 1 and 12.
multiply : Multiplies numbers together and returns the result.
notEquals : Evaluates a boolean and returns the opposite boolean value; i.e. when passed an expression that evaluates to true, $not returns false; when passed an expression that evaluates to false, $not returns true.
or : Evaluates one or more expression s and returns true if any of the expression s are true. Otherwise, $or returns false.
param : Creates a parameter (i.e., a field whose value can be modified by a user viewing the widget.).
The first argument is the parameter’s name and the second argument is its default value. For more info, see Adding Parameters through the Display Field and Group Stages .
power : Raises a number to the specified exponent and returns the result.
Regexmatch : Returns ‘True’ if the field value matches regex.
Example Expression
regexMatch(UOM,PALLET)Example Input
Result
round : Rounds a number to a specified number of digits.
second : Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.
sizeOfArray : Counts and returns the total the number of items in an array.
splitString : Divides a string into an array of substrings based on a delimiter.
sqrt : Calculates the square root of a positive number and returns the result.
stringLength : Looks at a string and returns the number of characters in it.
substring : Returns a substring of a string, starting at a specified index position and including the specified number of characters.
subtract : Subtracts two numbers to return the difference, or two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date.
sum : Calculates and returns the sum of numeric values.
sysdate : Returns the system date in Coordinated Universal Time (UTC) i.e., Greenwich Mean Time.
For more info, see Building Widgets that Refer to the System Date . In the example, the function is run on May 1st, 2023.
sysdatetz : Returns the system date in the WMS’s local time zone.
For more info, see Building Widgets that Refer to the System Date . In the example, the function is run on May 1st, 2023.
toDate : Converts a value to a date.
toDouble : Converts a value to a double.
toInteger : Converts a value to an integer.
toString : Converts a value to a string.
truncate : Truncates a number to its integer.
upperCase : Converts a string to uppercase, returning the result.
weekOfYear : Returns the week of the year for a date as a number between 0 and 53.
year : Returns the year portion of a date.
Note
Group functions are divided into two categories: aggregation functions, which group data together (e.g., sum, average, min, max); and embedded functions, which must be included inside an aggregation function.
Functions that return true/false results should be embedded inside the condition function, which should be wrapped inside an aggregation function. The condition function is particularly useful for getting a count of records that meet spcified criteria.
Aggregation Functions
average : Returns the group’s mean value for the specified field.
buildArray : Selects a comma-separated set of unique values from the specified field and adds them to an array.
first : Returns the first value in a data set.
last : Returns the last value in a data set.
max : Returns the group’s maximum value for the specified field.
If the field stores string values, the function returns the maximum string value based on lexicographic order.
min : Returns the group’s minimum value for the specified field.
If the field stores string values, the function returns the minimum string value based on lexicographic order.
sum : Returns the sum of all the values in the specified field for each group.
Embedded functions
absolute : Returns the absolute value of a number.
add : Adds numbers together or adds numbers and a date.
and : Evaluates one or more expression s and returns true if all of the expression s are true or if evoked with no argument expression s. Otherwise, $and returns false.
To aggregate the true/false results, embed the and function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if the PICK_QUANTITY value is greater than 50 and less than 100; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
sums the records that have PICK_QUANTITY greater than 50 and less than 100. For each record that meets the condition, the function returns a value of 1, otherwise it returns a value of 0.
ceil : Returns the smallest integer greater than or equal to the specified number.
compare : Compares two values and returns: ‘-1’ if the first value is less than the second; ‘1’ if the first value is greater than the second; and ‘0’ if the two values are equivalent.
condition : Evaluates a boolean expression to return one of the two specified return expression s.
Either of the two possible return expressions can be a null value. In the example, the function returns a value of 1 if SHIPMENT_STATUS is D, L, or S; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
dateToString : Converts a date object to a string according to a user-specified format.
Function format: dateToString(DATE_FIELD, “OUTPUT FORMAT”, timezone[optional], value to return if date is null or missing.)
dayOfMonth : Returns the day of the month for a date as a number between 1 and 31.
dayOfWeek : Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
dayOfYear : Returns the day of the year for a date as a number between 1 and 366.
divide : Divides one number by another and returns the result.
Note
If the denominator is zero, no result will be returned. There will not be any error message. To prevent this from happening, you can nest a condition function as the argument for the denominator. e.g.,
divide(FIELD1, condition(equals(FIELD2, 0), 1, FIELD2))
Example Expression
divide(ORDER_QUANTITY, SHIPPED_QUANTITY)Example Input
Result
equals : Compares two values and returns: ‘true’ when the values are equivalent. Otherwise, ‘false’.
To aggregate the true/false results, embed the equals function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if USR_ID equals “BETTY”; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
exp : Raises Eulers number (i.e. e ) to the specified exponent and returns the result.
findSubstring : Searches a string for a substring and returns the index (zero-based) of the first instance. If the substring is not found, returns -1.
getElementFromArray : Returns the element at the specified array index.
in : Returns TRUE if the record’s specified field has any of the values enclosed in the square brackets.
Each value should be enclosed in double quotes. Format: in (FIELD_VALUE_TO_TEST, [“ArrayElement1”,”ArrayElement2”]). To aggregate the true/false results, embed the in function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if USR_ID equals either “WILMA”, “BETTY”, “FRED”, or “BARNEY”; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
isNull : Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.
If the expression evaluates to a null value, including instances of undefined values or missing fields, returns the value of the replacement expression. In the example, the isNull function returns the value “No customer name” if CUST_NAME of a record stores a null value. The condition function returns a value of 1 if the record has a value equal to “No customer name”; otherwise, it returns a value of 0. The expression them sums the number of records that meet the specified condition.
isoDayOfWeek : Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).
isoWeek : Returns the week number in ISO 8601 format, ranging from 1 to 53.
Week numbers start at 1 with the week (Monday through Sunday) that contains the year’s first Thursday.
isoWeekYear : Returns the year number in ISO 8601 format.
The year starts with the Monday of week 1 and ends with the Sunday of the last week.
lessThan : Compares two values and returns ‘true’ when the first value is less than the second value. Otherwise it returns false.
To group the true/false results, the and function must be wrapped inside the condition function, before it’s embedded in an aggregation function. To aggregate the true/false results, embed the lessThan function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if the SHIPPED_QUANTITY value is less than the ORDER_QUANTITY value; otherwise, it returns a value of 0. The expression then sums the records that meet the specifid condition.
lessThanOrEqual : Compares two values and returns ‘true’ when the first value is less than or equal to the second value. Otherwise it returns false.
To group the true/false results, the and function must be wrapped inside the condition function, before it’s embedded in an aggregation function. To aggregate the true/false results, embed the lessThanOrEqual function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if the ORDER_QUANTITY value is less than or equal to the SHIPPED_QUANTITY value; otherwise, it returns a value of 0. The expression then sums the records that meet the specifid condition.
ln : Calculates the natural logarithm ln (i.e log e) of a number and returns the result as a double.
log : Calculates the log of a number in the specified base and returns the result as a double.
log10 : Calculates the log base 10 of a number and returns the result as a double.
lowerCase : Converts a string to lowercase, returning the result.
millisecond : Returns the millisecond portion of a date as an integer between 0 and 999.
min : Returns the minimum value from the argument s.
minute : Returns the minute portion of a date as a number between 0 and 59.
modulus : Divides one number by another and returns the remainder.
month : Returns the month of a date as a number between 1 and 12.
multiply : Multiplies numbers together and returns the result.
notEquals : Evaluates a boolean and returns the opposite boolean value; i.e. when passed an expression that evaluates to true, $not returns false; when passed an expression that evaluates to false, $not returns true.
To aggregate the true/false results, embed the notEquals function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if USR_ID does not equal “BETTY”; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
or : Evaluates one or more expression s and returns true if any of the expression s are true. Otherwise, $or returns false.
To aggregate the true/false results, embed the or function inside the condition function and wrap the condition function inside the desired aggregation function. In the example, the condition function returns a value of 1 if the PICK_QUANTITY value is greater than 50 or less than 20; otherwise, it returns a value of 0. The expression then sums the records that meet the specified condition.
param : Creates a parameter (i.e., a field whose value can be modified by a user viewing the widget.).
The first argument is the parameter’s name and the second argument is its default value.
Note
This function can be used only as an argument inside another function. For more info, see Adding Parameters through the Display Field and Group Stages .
Example Expression
average(multiply(TOTAL_HOURS_WORKED,param(AVG_PAY,15)))Example Input
Result
power : Raises a number to the specified exponent and returns the result.
second : Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.
splitString : Divides a string into an array of substrings based on a delimiter.
splitString removes the delimiter and returns the resulting substrings as elements of an array. If the delimiter is not found in the string, splitString returns the original string as the only element of an array.
sqrt : Calculates the square root of a positive number and returns the result.
stringLength : Looks at a string and returns the number of characters in it.
substring : Returns a substring of a string, starting at a specified index position and including the specified number of characters.
subtract : Subtracts two numbers to return the difference, or two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date.
sysdate : Returns the system date in Coordinated Universal Time (UTC) i.e., Greenwich Mean Time.
For more info, see Building Widgets that Refer to the System Date .
sysdatetz : Returns the system date in the WMS’s local time zone.
For more info, see Building Widgets that Refer to the System Date .
toDate : Converts a value to a date.
If the value can’t be converted, an error will be returned.
toDouble : Converts a value to a double.
If the value can’t be converted, an error will be returned.
toInteger : Converts a value to an integer.
If the value can’t be converted, an error will be returned.
toString : Converts a value to a string.
If the value can’t be converted, an error will be returned.
truncate : Truncates a number to its integer.
upperCase : Converts a string to uppercase, returning the result.
weekOfYear : Returns the week of the year for a date as a number between 0 and 53.
Weeks begin on Sundays, and week 1 begins with the first Sunday of the year. Days preceding the first Sunday of the year are in week 0.
year : Returns the year portion of a date.