Modifier
Modifiers transform data on the fly within a flow. They allow you to apply a JSONata or JavaScript expression to change the structure or value of an output before passing it to the next function, a database, the frontend, or a subsequent extension (such as another modifier or filter).
Modifiers are part of the function extensions. To add a modifier to your function:
Click the
+icon on the right side of any function output, filter, or existing modifier.Select modifier from the list.
A new modifier box will appear where you can write your JavaScript logic.
A modifier uses either JSONata or a JavaScript expression. You can switch between types by right-clicking the modifier and selecting JSONata or Expression and adjust the default inside the App Builder settings.

Need help writing modifiers? Read about how to best use AI for writing modifiers to generate JSONata or JavaScript logic instantly using your favorite chatbot.
JSONata
JSONata is a query and transformation language designed for JSON data. It is the preferred method for structural changes, filtering, and simple math. For a complete guide, refer to the official JSONata documentation.
Reference: Use the
$sign to refer to the value from the preceding output.Implicit arguments: In Heisenware, JSONata modifiers automatically process the incoming data if the parentheses are left empty. For example,
$uppercase()is equivalent to$uppercase($).
JSONata examples
Example 1: Path selection and math
Extracts a specific nested value from a PLC object and performs a calculation.
Data:
Modifier content:
Return of the modifier:

Example 2: Wrap a value in an object
Takes the incoming value ($) and wraps it inside a JSON object with a key named temp_sensor_1.
Data:
Modifier content:
Return of the modifier:

Example 3: Implicit function usage
Trims whitespace and converts a raw string to uppercase without explicitly naming the input variable.
Data:
Modifier content:
Return of the modifier:

Example 4: Filtering an array
Returns only the objects from a list that meet a specific status condition.
Data:
Modifier content:
Return of the modifier:

JavaScript expressions
This modifier allows you to use any standard JavaScript expression that evaluates to a new value. Reference the reserved variable x to access the preceding data output. For more information, refer to the MDN documentation for JavaScript Expressions and Operators.
JavaScript expression examples
Example 1: Conditional status (Ternary)
Determines a status string based on a numeric threshold.
Data:
Modifier content:
Return of the modifier:

Example 2: Array mapping and enrichment
Iterates through an array of objects to add a new property or modify existing ones using the .map() function.
Data:
Modifier content:
Return of the modifier:

Example 3: Multi-step logic (IIFE)
While modifiers only support expressions, you can use the Immediately Invoked Function Expression (IIFE) pattern for more elaborate logic involving temporary variables.
Data:
Modifier content:
Return of the modifier:

Example 4: Removing and adding properties in an array
Use the spread operator (...) to reproduce existing entries while selectively removing or adding properties.
Data:
Modifier content:
Return of the modifier:

Example 5: Processing multiple inputs (using combine function)
When using the combine function, the IIFE pattern allows you to cleanly handle multiple input sources stored in the x array.
Data (combined by the combine function):
Modifier content:
Return of the modifier:

Example 6: Date calculations (using Luxon)
Heisenware provides built-in support for the Luxon library via the DateTime object for complex time-series operations.
Data:
Modifier content:
Return of the modifier:

Example 7: Round robin (using combine function)
Sometime you want to extract items of an array in a round-robin fashion. For that you can use a combine function in which you link back the modifier's output to the second argument:

Data:
Modifier content:
Return of the modifier:
Using AI for modifiers
You can use AI chatbots (ChatGPT, Claude, Gemini) to generate or optimize your modifiers. This is particularly helpful for complex data transformations where you need to reshape large JSON objects on the fly within the Heisenware visual programming environment.
To optimize results, copy this article as context for the AI. Use the Copy button at the top of the page or the direct Open in ChatGPT / Open in Claude buttons located in the top navigation bar.
Recommended AI prompt
Alternatively to using the full article, copy and paste this prompt into your AI to ensure it understands the Heisenware environment and specific variable references.
Last updated
Was this helpful?