ServiceNow Formula Builder is a feature that allows you to create complex formulas in the platform. It is a tool that allows developers to write formulas that create calculated fields with a simple, no-code syntax.
It is integrated with Table Builder, allows users to search for functions, and provide syntax guidance during formula composition.
- Formula fields with an intuitive, no-code syntax
- Built-in functions such as SUM, DIVIDE, and IF
- Syntax guidance for clarity when writing formula
- Error debugging to help construct correctly formatted formulas
Not only is it easier to write and read a formula over a script, but formulas are also more accurate than scripts due to the fact that JavaScript can have problems with floating-point arithmetic which can be a big problem for financial calculations. Formulas, which are using arbitrary precision, are more accurate in this way.
This feature is also available in APP ENGINE STUDIO. And use it with Table Builder, where you have a section using formulas where you can select the field.
It also validates the syntax, if you misspell a column name, you will receive an invalid-update error when trying to save the dictionary entry. Incorrect function names are also validated. Nevertheless, I'll provide you with the general steps for using Formula Builder in ServiceNow:
1. Accessing Formula Builder:
- Log In to your ServiceNow instance
- Navigate to the form where you want to create the formula.
2. Using the Formula Builder:
- Right Click the field --> Configure dictionary --> Go to advanced view
- Navigate to the Calculated Value section/tab
- Check the Calculated Checkbox
- Select "Formula" in the Calculation Type
- Build your calculation's formula in the formula field
- Save your Record
3. Examples of Possible Formulas:
a. CONCATENATE ( first_name, " ." , last_name, "@", org name, ".com " )
Combines two field string values into a third field
b. SUM ( price_1, price_2)
Adds the two field values and gives the sum
c. TIMEDIFF ( user.dob, NOW() )
Calculates the difference between the user's birthday and today's date
- Formulas can have the following:
- Functions like SUM, MULTIPLY, AVERAGE, REPLACE, LOWERCASE, UPPERCASE
- Variables like column names. These include the dot-walked fields. It should be the column label.
- Operators like =(equals) , +(plus) , <=(greater than equals to) , /(divide) are not supported.
- Constants like string or numeric values are enclosed in double-quotes. Example - "hello"
- SUM- Performs the addition on all arguments.
- MULTIPLY - Performs the multiplication of arguments.
- REPLACE - Replaces characters in the source string with characters in the target string.
- AND - Performs a logical AND operation on the arguments.
- OR - Performs logical OR operation on the arguments.
- AVERAGE - Returns the average value of the arguments.
- DIVIDE - Returns the quotient value after dividing argument 2 by argument 1.
- IF - Executes the specified statements based on the Boolean output of the expression.
- POWER - Returns the result of the base value raised to the power of the exponent value.
- CONCATENATE - Merges two or more string values into one.
- LOWERCASE - Converts the string values to lowercase.
- UPPERCASE - Converts the string values to uppercase.
- MAX - Returns the highest value in the arguments.
- NOW - returns the current date and time of the instance.
- TIMEDIFF - Finds difference between two dates of duration field.
- LENGTH - Returns the total number of characters in the argument.
- ISBLANK - Finds the white spaces or blank values in the argument and returns a Boolean value.
- TITLECASE - Converts the input string to all title case characters.