Field Formulas
Field formulas allow you to perform logic, date, and math formulas on the contents of a field. These formulas reference values in other fields, allowing you to perform operations like concatenating two fields, adding or averaging the values of several number fields, and date calculations such as number of years between two dates. The formula is dependent on values of other fields; it will appear blank until those fields are filled. Once the field has been populated and the user has clicked out of the field, the formula will be applied to that value. Additional fields populated will cause the formula to update the value.
The formula is dependent on values of other fields; it will appear blank until those fields are filled. Once the field has been populated and the user has clicked out of the field, the formula will be applied to that value. Additional fields populated will cause the formula to update the value.
You can also specify that the field should be read-only, so that users can't modify the calculated value.
Field formulas can only be applied and used in the Laserfiche Repository Web Client. The formulas you create will not be applied to documents through other applications such as Workflow, Import Agent, or the Repository Desktop Client.
Adding a Formula to a Field
To add a field formula to a field, perform the following steps:
- Open the Laserfiche Repository Web Client and select your user name in the upper right corner, then select Administration.
- Select the Metadata section in the left-hand menu.
- Select the Templates tab.
- Open the template to which you want to add a formula. See Creating and Modifying Fields and Templates if you need to create a new field.
- Determine the fields that will contribute to the template, and the field that will contain the final value. For example, if you want to average several fields, you would first identify or create the fields containing the numbers to be averaged. and then identify or create a field to contain the final average.
- Select the field that will contain the final value. In the panel to the right, select the Advanced tab.
- In the Formula option, type your formula. See Formula Reference, below, for more information. You can also select the Insert function and Insert field buttons to display and select from a list of supported formulas and a list of field in the template.
- Optional: To ensure that users don't change the final calculation, you can select the Display field as read-only option. Note that this is not a security feature; if the field exists in another template, it will not be read-only there.
- Select Save to save your formula.
Examples
Adding Field Values with =SUM()
An administrator wants to create a formula to add the values of three numbers (fields "One," "Two," and "Three,") and store it in a fourth "Total" field. The administrator could create a formula in the "Total" field and use the =SUM function to add the three other fields, with a syntax of =SUM(FIELD("One", "Two","Three")). When a user populates a any of the three fields that are being added together, and then clicks out of that field, the formula in the field "Total" will be updated. When all three of the fields are filled, the "Total" field will show the final value.
Concatenating Field Values with =CONCATENATE()
The template you are updating contains a "First Name" field, a "Last Name" field, and a "Full Name" field. An administrator has configured the "Full Name" field to concatenate the other two fields, last name first, using the formula =CONCATENATE(FIELD("Last Name"),", ",FIELD("First Name")). When a user populates a value in the "Last Name" field and clicks out of that field, the last name will be inserted into the "Full Name" field; when the "First Name" field is populated, its value will also be inserted in the "Full Name" field. This also works if the "First Name" field is populated before the "Last Name" field.
Formula Reference
The supported formulas for a field are in the OpenFormula standard. The OpenFormula standard is the same standard used by Microsoft Excel and Google Sheets. Note that the formula names are case sensitive and should be written in all caps.
| Name | Format | Description | 
|---|---|---|
| ABS | ABS(value) | The ABS function returns the absolute value of the specified value. 
 | 
| ADD | ADD(value1, value2) | The ADD function returns the sum of two values. 
 | 
| ADD_MONTHS | ADD_MONTHS(date, months) | The ADD_MONTHS function adds months to a date object and returns a date object. 
 | 
| AND | AND(value1, value2, ...) | The AND function returns "true" if all specified values are true; otherwise, it returns false. 
 | 
| AVERAGE | AVERAGE(value1, value2, ...) | The AVERAGE function returns the average of a list of values. 
 | 
| AVERAGEIF | AVERAGEIF([value1, value2, ...], criterion) | The AVERAGEIF function returns the average of a list of number values that satisfy the criterion. 
 | 
| AVG | AVG(value1, value2, ...) | The AVG function returns the average of a list of values. 
 | 
| CEILING | CEILING(value, factor) | The CEILING function rounds the specified value up to the nearest multiple of the factor. 
 | 
| COLUMN | COLUMN() | The COLUMN function returns the column number of a cell in a table. The first cell has a value of 1. 
 | 
| CONCATENATE | CONCATENATE(value1, value2, ...) | The CONCATENATE function joins multiple strings together into one string. Also see JOIN. 
 | 
| COUNT | COUNT(value1, value2, ...) | The COUNT function tallies the number of non-numeric, listed values. 
 | 
| COUNTIF | COUNTIF([value1, value2, ...], "condition") | The COUNTIF function tallies the number of listed values that satisfy the condition. 
 | 
| DATE | DATE(year, month, day) | The DATE function returns a date object representation of a date. You can use this date object in various other functions, including DAY, MONTH, and YEAR. 
 Note: When used with a date-based variable or field, the date will be formatted as defined by the field or variable. | 
| DATEDIF | DATEDIF(start_date, end_date, time_unit) | The DATEDIF function calculates the difference between two date objects based on a specific unit. 
 | 
| DATEVALUE | DATEVALUE(dateString) | The DATEVALUE function converts a date (stored as text) into a date object. 
 | 
| DAY | DAY(dateValue) | The DAY function returns the day of a given date. 
 | 
| DAYS360 | DAYS360(start_date, end_date) | The DAYS360 function returns the number of days between two given dates. This is sometimes used in financial interest calculations. 
 | 
| DIV | DIV(value1, value2) | The DIV function divides the first value by the second value. 
 | 
| EDATE | EDATE(DateObject, months) | The EDATE function adds an integer number of months to a date object to return another date object. If the months are non-integer values, then the function is rounded and then added. 
 Note: When used with a date-based variable or field, the date will be formatted as defined by the field or variable. | 
| EOMONTH | EOMONTH(DateObject, months) | The EOMONTH function adds an integer number of months to a date object then returns a date object with the day as the end of that month. 
 Note: When used with a date-based variable or field, the date will be formatted as defined by the field or variable. | 
| EQ | EQ(value1, value2) | The EQ function returns "true" if the two values are equal, "false" otherwise. 
 | 
| FIND | FIND(targetText, textToSearch, startingCharacter) | The FIND function returns the number of digits before finding the first value in the second value. The function performs the search starting with the starting character. 
 | 
| FIXED | FIXED(value, significance) | The FIXED function returns a number based on a specific number of significant digits. 
 | 
| FLOOR | FLOOR(value, factor) | The FLOOR function rounds the specified value down to the nearest multiple of the factor. 
 | 
| GT | GT(value1, value2) | The GT function returns "true" if the first value is greater than the second, "false" otherwise. 
 | 
| GTE | GTE(value1, value2) | The GTE function returns "true" if the first value is greater than or equal to the second, "false" otherwise. 
 | 
| IF | IF(booleanValue, value1, value2) | The IF function returns the second value when the first value is true, otherwise returns the third value. 
 | 
| INDEX | INDEX(column, row) | The INDEX function returns a specific item in an array. 
 | 
| JOIN | JOIN(delimiter, array) | The JOIN function concatenates the values in an array into one string. Each value is separate by the delimiter. Also see CONCATENATE. 
 | 
| LEFT | LEFT(string, [characters]) | The LEFT function returns all the characters from the left up to a specific number of characters. 
 | 
| LOWER | LOWER(text) | The LOWER function converts a text value into lowercase. 
 | 
| LT | LT(value1, value2) | The LT function returns "true" if the first value is less than the second, "false" otherwise. 
 | 
| LTE | LTE(value1, value2) | The LTE function returns "true" if the first value is less than or equal to the second, "false" otherwise. 
 | 
| MAX | MAX(value1, value2, ...) | The MAX function returns the maximum numerical value in a list of values. The function ignores non-numeric values. 
 | 
| MIN | MIN(value1, value2 ,...) | The MIN function returns the minimum numerical value in a list of values. The function ignores non-numeric values. 
 | 
| MINUS | MINUS(value) | The MINUS function returns the opposite of the current number sign. 
 | 
| MOD | MOD(value1, value2) | The MOD function returns the remainder from dividing the first number by the second. Learn more 
 | 
| MONTH | MONTH(dateValue) | The MONTH function returns the month (from 1 to 12) in a date object. 
 | 
| MULT | MULT(value1, value2) | The MULT function returns the first value multiplied by the second. 
 | 
| NEQ | NEQ(value1, value2) | The NEQ function returns "true" if the two values are not equal, "false" otherwise. 
 | 
| NETWORKDAYS | NETWORKDAYS(startDate, endDate, [holidays], [weekDays]) | The NETWORKDAYS function returns the whole number of work days between two date objects. 
 | 
| NOT | NOT(value) | The NOT function returns "true" if the value is false, or "false" if the value is true. 
 | 
| NOW | NOW() | The NOW function returns the current date and time. 
 | 
| OR | OR(value1, value2, ...) | The OR function returns "true" if any of the specified values are true, "false" otherwise. 
 | 
| PROPER | PROPER(text) | The PROPER function returns the specified text value with the first letter in a text string and any other letters in the string that follow any character other than a letter converted to uppercase. 
 | 
| REPLACE | REPLACE(old_string, start_position, count, new_string) | The REPLACE function returns a text value from modifying the first value at the location from the second value to the third value based on the fourth value. 
 | 
| RIGHT | RIGHT(value, n) | The RIGHT function returns all the characters from the right up to a specific number of characters. 
 | 
| ROUND | ROUND(value, places) | The ROUND function returns the value rounded to the specified number of decimal places. 
 | 
| ROUNDDOWN | ROUNDDOWN(value, places) | The ROUNDDOWN function returns the value rounded down to the specified number of decimal places. 
 | 
| ROUNDUP | ROUNDUP(value, places) | The ROUNDUP function returns the value rounded up to the specified number of decimal places. 
 | 
| ROW | ROW() | The ROW function returns the row number of a cell in a table. The first cell has a value of 1. 
 | 
| SPLIT | SPLIT(textValue, textSplit) | The SPLIT function returns an array of values, where the first value is split up based on the method for splitting. 
 | 
| SUB | SUB(value1, value2) | The SUB function returns the difference between the first and second values. 
 | 
| SUBSTITUTE | SUBSTITUTE(text, target text, replacement text, number) | The SUBSTITUTE function replaces existing text values with updated text values. The "number" parameter is optional, and specifies the position of found instances to replace if there is more than one. "=SUBSTITUTE("Employees: Susan Marks, Paul Smith, Eric Marks", "Marks", "Johnson", 1)" returns "Employees: Susan Johnson, Paul Smith, Eric Marks" "=SUBSTITUTE("Employees: Susan Marks, Paul Smith, Eric Marks", "Marks", "Johnson", 2)" returns "Employees: Susan Marks, Paul Smith, Eric Johnson" | 
| SUM | SUM(value1, value2, ...) | The SUM function calculates the sum of all the number values in a list. 
 | 
| SUMIFS | SUMIFS(reference, range1, criterion1, range2, criterion2, ...) | =SUMIFS([1,1,3], [3,2,3], ">2", [4,5,6], "<6") returns "1", because the first value in range 1 is "3" and the first value in range 2 is "4". "3" fits criterion 1 because 3 is greater than 2 and "4" fits criterion 2 because 4 is less than 6, so "1" (in the reference) is a hit. Similarly, the second "1" is a hit. However, "3" is not a hit because 6 is not less than 6 in the second range. | 
| TEXT | TEXT(number) | The TEXT function converts a specified value to a string. 
 | 
| TRIM | TRIM(text) | The TRIM function removes spaces before and after a specified value. 
 | 
| TRUNC | TRUNC(value1, value2) | The TRUNC function shortens (or "truncates") the first value to the number of decimal places in the second value. If the second value is absent or set to zero, the function shortens to an integer. 
 | 
| UPPER | UPPER(text) | The UPPER function converts the specified text to all uppercase letters. 
 | 
| VALUE | VALUE(input) | The VALUE function converts a specified value to a number. 
 | 
| WEEKDAY | WEEKDAY(date, [type]) | The WEEKDAY function returns the day of the week for the specified date as a number. You can type "1", "2", or "3" to determine whether the first day of the week is a Sunday or Monday. 
 | 
| WEEKNUM | WEEKNUM(date, mode) | The WEEKNUM function returns the number of the week in a year for a specified date object. 
 | 
| WORKDAY | WORKDAY(startDay, numDays) | The WORKDAY function returns a date object based on the number of days after a start day. 
 | 
| YEAR | YEAR(dateValue) | The YEAR function returns the year of a given date object. 
 |