Skip to main content

Make calculations via SmartFields

How to work with dynamic fields and formulas in prduct.com

Andreas Stensig avatar
Written by Andreas Stensig
Updated this week

SmartFields are dynamic fields that automatically calculate or compose data based on other fields. They are used for e.g. price calculations, weight calculations, text combinations, and integration data.


When input changes, the SmartField updates automatically and displays as a read-only result.

Video walkthrough

Preparation: create input fields first

Before you create a SmartField, you should create the fields that will be used as inputs. A SmartField must have some input fields; if they do not already exist, we recommend creating them beforehand.

Example:

  • Field 1: Price

  • Field 2: Tax

  • SmartField: Calculates price including tax

It is possible to use fields that do not yet exist if you know their names – but it is easier to create them first.

Create a SmartField

  1. Create a new custom field as usual.

  2. Select the type SmartField.

  3. Drag the field into place (drag & drop).

  4. Click the gear icon or the field itself to open the settings.

You can now configure the SmartField.

Basic settings

In the SmartField settings, you must set the following:

  • Label name
    The name the user sees. Used only for display.

  • Model name
    Used internally in the system. Primarily technical.

These two are not critical for functionality.

Next, you must choose the mode.

Choose SmartField mode (expression / template)

You must choose how the field will function.

Template = string (text)

Used when:

  • You want to assemble text

  • You want to combine values as text

Example:

{{FieldName1}} {{FieldName2}}

This simply displays the text. No calculation is performed.

Tip: Use “Insert attribute” to choose a specific attribute and insert it into the formula.

You can combine fields however you like. If you insert e.g. a space or symbol in between, it will be shown as part of the text.

The attribute must be wrapped in {{ and }} when using this mode.

Expression = calculation (number)

Used when:

  • You want to perform calculations

Supported calculations:

  • Plus: +

  • Minus: -

  • Multiply: *

  • Divide: /

  • Parentheses: ()

Examples:

[Price]*[Tax]
[Weight1]+[Weight2]
 ([Price]+[Fee])*2
[Quantity]/[Weight]

Tip: Use “Insert attribute” to choose a specific attribute and insert it into the formula.

The attribute must be wrapped in [ and ] when using an expression.

Choose output type

You must choose what the SmartField should return.

Possible output types

  1. Number (numeric)

    • Used for calculations

    • Can optionally be used in other SmartFields

  2. String (text)

    • Used for text composition

  3. JSON

    • Used primarily for integrations

    • The system ensures correct formatting

    • Used for integration with external systems to avoid manually writing JSON strings

The output is shown directly in the SmartField as the calculated result.

Insert attributes into the formula

When you create the SmartField, you can choose your input fields from a dropdown.

The fields are inserted as attributes in the formula.

For string

  • Fields are inserted directly

  • You can write spaces, text, and symbols between them

Example:

{{ProductName}} {{Variant}}

For math / expression

  • Fields are inserted in square brackets

Example:

[Weight]*[Quantity]

Placement and updating

  • The result is shown directly in the SmartField

  • No extra field is created

  • The SmartField is read-only

  • It updates automatically when input fields change

The system monitors input fields and recalculates automatically.

Requirement: The fields must be on the same document/entity to be used together.

Changing existing SmartFields

You can change the SmartField’s output type and mode on an existing SmartField.

Be aware of possible formatting changes and whether attributes are written with {{ }} or [ ].

Be cautious when changing the type of an input field. For example, changing an input field from text to number can cause errors. In general, we recommend creating a new field instead.

Examples of SmartField setups

Price including tax

Input:

  • Price

  • Tax

Formula:

[Price]*[Tax]

Output: Number

Package weight

Input:

  • Weight

  • Quantity

Formula:

[Weight]*[Quantity]

Output: Number

Composed text

Input:

  • Product name

  • Variant

Formula:

{{ProductName}} {{Variant}}

Output: String

JSON for integration

Input: Several attributes
Output: JSON

The system ensures correct formatting.

Alternative solutions for conditions

If you need dependent fields (for example: HS code → description):

This is not handled in SmartFields. Instead, use business rules.

Did this answer your question?