Skip to main content

Formula Context Object

Every formula function receives a single info parameter containing the following properties:
Formulas execute during cell rendering. When a formula result differs from the stored value, Risksheet can mark the item as edited. Formula changes respect the readOnly column setting. This means formulas only run when their column is visible in the current view.

How Formulas Are Defined

Formulas are declared as named entries in the top-level formulas object of sheet configuration. Each entry is a JavaScript function written as a string value:
A column references a formula by setting its formula property to the formula name:
diagram

Column Properties for Formula Columns

When formula is set on a column, Risksheet automatically makes the column read-only. If you set readOnly: false on a formula column, changes made outside Risksheet may drift from formula-calculated values. Use Menu > Rows > Check stored formulas to reconcile stored values with recalculated formula output (available since v24.5.1).

Data Access Functions

Direct Field Access

Access any field on the current work item using the column binding ID:
Common field access patterns:

Linked Item Field Access

For item link columns, the _link suffix provides the pre-rendered HTML hyperlink:

Built-In Formula Patterns

RPN Calculation (Initial Assessment)

The standard Risk Priority Number formula multiplies severity, occurrence, and detection ratings. This is the most common formula in FMEA configurations:
Return behavior: Returns the product of all three values. If any value is falsy (zero, null, or undefined), returns null to avoid displaying zero for incomplete rows.

RPN Calculation (After Mitigations)

The revised RPN uses the post-mitigation rating fields to show the residual risk after corrective actions:

Null-Safe Multiplication

Always guard against null inputs to avoid NaN results when data is incomplete:

Cross-Row Data Aggregation

getMasterRowsByColumnValue

Available since v24.9.1 The risksheet.ds.getMasterRowsByColumnValue() function enables cross-row data aggregation. This is critical for FMEA workflows where parent process step rows need to summarize characteristics from child risk items. Use case: Aggregate unique enum values from downstream risk items In a process FMEA, the parent process step may need to collect all unique process characteristics from its child risk items:
Expanded for readability:
Use case: Sum numeric values across child items
Use the summation pattern for rolling up numeric risk scores or counts. Use the unique-value pattern for collecting distinct enum values (e.g., process characteristics, risk categories) from multiple child risk items into a parent row.

String Functions

Field Concatenation

Combine multiple field values into a single display string:

Auto-Generated Title

Automatically construct a title from component fields:

Conditional Logic Functions

Risk Matrix Lookup

Implement a risk acceptance matrix using conditional logic:

Enum-Based Conditional

Compare against enum IDs (not display names):
Formula comparisons must use enum IDs (e.g., 'mitigated'), not display values (e.g., 'Mitigated'). The enum type identifier in sheet configuration must match the definition in Polarion’s XML custom field file. Check your .polarion/documents/fields/custom-fields.xml for the correct ID values.

Top Panel Function Integration

For complex calculations that exceed inline formula capacity, define functions in the risksheetTopPanel.vm file and call them from formulas. This pattern is also the only way to access document-level custom fields or external data sources.

Pattern Overview

The formula in sheet configuration calls a function defined in risksheetTopPanel.vm:
Step 1. Define a JavaScript function in risksheetTopPanel.vm:
Step 2. Reference the top panel function from a formula in sheet configuration:

Accessing Document Custom Fields via Top Panel

Document-level custom fields are not directly available in sheet configuration formulas. Access them via $doc.getOldApi().getValue('customFieldID') in the risksheetTopPanel.vm Velocity script section, then bridge the values into your formulas through global JavaScript functions:
Then reference from sheet configuration:
The risksheetTopPanel.vm can reference external data sources via Velocity context and Polarion APIs (e.g., reading risk acceptance matrix values from an XML sheet configuration). This enables dynamic risk matrix definitions shared across projects without duplicating formula logic in each sheet configuration.

Accessing Work Item Data in Top Panel Functions

Work item data can be accessed in top panel functions via info.item['fieldId']. Prepare all needed values within functions defined in the top panel file, then return the result to sheet configuration formulas:

Formulas and Cell Decorators

Formulas compute the value; cell decorators apply visual styling based on that value. The two work together but are configured separately in sheet configuration.
diagram
The cellDecorators entry for RPN values applies CSS classes based on risk thresholds:

RPN Risk Threshold CSS Classes

Row Header Decorator

The row header can also display risk color based on the revised RPN value:
For full cell decorator reference, see Cell Decorators.

Formula Visibility and Execution

Formulas execute during cell rendering, which means a formula only runs when its column is visible in the current view.
If a formula column is hidden (not visible in the current saved view), its formula does not execute. If other formulas or cell decorators depend on the hidden column’s value, they will read a stale or null value. Use Saved Views for export-specific layouts, but never set an export-only view as the default view since formulas run on sheet load.

Check Stored Formulas

Available since v24.5.1 When formula columns have readOnly: false, or when items are edited outside Risksheet (for example, through Polarion’s standard work item editor), stored values may drift from formula-calculated results. To reconcile:
  1. Open the Risksheet document
  2. Navigate to Menu > Rows > Check stored formulas
  3. Risksheet recalculates all formula columns and flags any differences
Formula-generated fields may trigger save failures when permissions restrict editing. If stored values differ from formula output (e.g., after data migration where titles were truncated), Risksheet tries to save the recalculated values, which are then blocked by permissions. Verify stored values match formula output before enabling strict permission enforcement.

Formula Return Types

Complete Example

A full FMEA configuration with initial and revised RPN formulas, cell decorators, row header styling, and corresponding CSS:
This configuration creates two RPN columns (initial and revised), each with color-coded risk thresholds applied via cell decorators. The row header uses the revised RPN color for at-a-glance residual risk assessment.
Last modified on July 10, 2026