Skip to main content

Set Default Value - Function Calculation


Similar to Excel's formula functionality, HAP provides various data processing functions. On the form editing page, after setting up function formulas for specific fields, the system will automatically calculate field values when users create or modify records data, eliminating the need for manual input and improving efficiency.

Function calculations can be used in the following three scenarios:

  • Formula fields

  • Field default value settings

  • Operation nodes in workflows

Five major categories of functions are supported: math function, date function, text function, logical function and advanced function.

Use Case

1. Using logical functions to derive different results

When field content needs to vary based on other field values, logical functions can be applied.

2. Using text functions to extract birthdates from ID numbers

Leverage text functions to identify and extract the birth year, month, and day from an ID number, then combine them into a new date format.

Function Configuration

Fields that support default value setting via functions: Text, Number, Currency, Date, Email, Telephone

Fields that can be used as function parameters: Text, Number, Currency, Email, Telephone, Date, Single-select, Multi-select, Members, Department, Check item, Region/City, ID Number, Subform, Relationship

Fields that cannot be used as function parameters: Level, Concat, Foreign field, Formula, Rollup, Auto-number, Rich Text, Cascading, File, Uppercase, Signature

Setting Field Default Values via Functions:

  1. On the form editing page, select the desired field.

  2. Click the dynamic default value button.

  3. Choose "Function Calculation" from the options.

You may then:

  • Select functions and field parameters from the left.

  • Or manually edit the function formula and static parameters.

Components of a Function Formula

A function formula typically consists of the following elements:

  • Function name
  • Parameters
  • Operators
  • Parameter seperators

Important Notes:

  • Parameters may be either field values or static values.
  • All operators and parameter seperators must use English symbols.
  • Not all elements are required in every function.
  • Multiple functions may be nested together.

Example function structure:

Test Functions

After editing your function formula:

  1. Click the "Test" button
  2. You may either:
    • Manually input field values for testing
    • Select an existing record to test against

Rules for Function Editing

1. Correct selection of functions and field parameters

  • Functions can be selected from the left panel or manually edited, but must be written in ALL CAPS when manually entered.

  • Field parameters must be selected from the left panel - they cannot be manually typed.

2. Proper selection of function types

Each function has a specific return type. When setting default values for a field, you must choose a function whose return type matches the field type.

Example: If you select DATENOW() for a number field (which returns a date/time value), no content will be displayed as they are incompatible types.

3. Operators

** **AdditionSubtractionMultiplicationDivisionGreater ThanEqual ToLess ThanGreater Than or EqualLess Than or EqualNot Equal
Operator+-*/>==<>=<=!=

Important Note: The equality comparison operator is "==" (double equals sign), not "=" (single equals). Example: IF(single-select field=='Option1',5,0)

4. Proper formatting of parameter

For functions like SUM(field1, field2) that calculate across multiple fields, parameters must be number types. If date-type fields are selected, the function won't process correctly and will return empty results.

Most functions require parameters, which fall into three main types:

  • Static values
  • Dynamic values
  • Combinations of static and dynamic values

1). Static parameters

Static parameters are fixed values that remain constant across calculations.

  • For text and date-type parameters:

    • Must be enclosed in single quotes (double quotes also acceptable)

    • Applies to: text fields, date fields, single-select fields

    Example 1: Getting the weekday for October 11, 2021:

    Example 2: Replacing digits 4-7 in phone numbers with *.

  • For number-type parameters:

    • Write the number directly without quotes
    • Example: Extracting phone number segments - specify starting position as 4 directly: MID(phone_field,4,4)

2). Dynamic parameters (field values or function results)

  • For field value parameters:

    • Select the field directly without quotes

    • Example 1: Rounding a decimal number

    • Example 2: Summing multiple number fields (only requires commas as separators)

  • For function result parameters:

    • Don't enclose in quotes

    • Example 3: Get the weekday of current date

3). Combined static and dynamic parameters

When combining static and dynamic parameters through concatenation:

  • The result becomes text-type and shouldn't be quoted
  • Use CONCAT function for combination

Example with DATEADD():

DATEADD(date_field,CONCAT('-',WEEKDAY(date_field)-1,'d'),1)

About DATEADD: Adds/subtracts time duration from a date

Format: DATEADD(date, '±duration', output_format)

Duration parameter format: ±numberunit (e.g., -1d = subtract 1 day, +3M = add 3 months) Requires CONCAT to combine:

Static elements: operators (-/+), units (d/M/y) Dynamic elements: calculated values

6. More function details and examples

Introduction to Functions