Skip to main content

Calculation Field Functionality

Creating powerful expressions in the calculation field.

Mike Meesseman avatar
Written by Mike Meesseman
Updated yesterday

Calculation fields allow you to write expressions that calculate values dynamically based on inputs from other fields in your apps. Whether performing simple totals or complex equations referencing repeatable sections, these fields provide real-time data processing.


Configuring a Calculation Field

When building an expression, the expression builder tool provides access to all field values within your app. The library includes searchable standard functions—similar to those found in Excel or Google Sheets—as well as Fulcrum-specific functions that reference record status, latitude, or longitude.



Expressions

View all available functions on the Fulcrum Developer Portal. Within the Code Editor, you can access a comprehensive list of available fields and functions to drive your calculations.

Example: Calculating Area

To calculate the area of a culvert based on user-entered width and length:

  1. Open the Code Editor.

  2. Use the SETRESULT function to multiply the fields.

  3. Your expression should look like this:


    SETRESULT($culvert_length * $culvert_width)

You can test your expression at the bottom of the Code Editor by entering sample values to verify the output before saving.

Process of setting up a simple expression to calculate the area of a culvert.


JavaScript Advanced Mode

For complex requirements, the code editor leverages raw JavaScript. This allows you to write custom functions and logic to return results from user data on-the-fly.


Display Formats

Select a format for displaying the expression result in the field options window. There are four available types:

Format of a Calculated Field set to Number

  • Text: Use for displaying strings or mixed values.

  • Number: Use exclusively for numeric values.

  • Date: Use for formatted date values (Format: YYYY-MM-DD).

  • Currency: Use for numeric values assigned to a specific currency.


Helpful Hints

Having trouble writing your expression? Maybe some of these tips will help:

Code in a text field and eval through a calculation field

This is a neat way to test expressions on a mobile device on-the-fly:

  1. Add a text field to your app. This is where you’ll enter JavaScript script.

  2. Add a calculation field to your app. Set the expression for this field to eval($code_field_data_name).

  3. Sync your mobile device, and now you can code using JavaScript into the text field. You’ll see the result work in the eval field!

INSPECT()

The INSPECT() function can be used to check the value being produced by any of the variables declared in your expression.

Process of using the INSPECT() function

Console.log()

console.log() can be used to display values in the developer's console in the web browser while troubleshooting your code.

var area = ($culvert_length*$culvert_width);
var volume = area * $culvert_depth;

console.log('Culvert Volume = '+ volume);

SETRESULT(volume);

You must remove all console.log() statements once troubleshooting is complete. Failure to remove these will cause the Fulcrum mobile app to malfunction or crash.

Did this answer your question?