Skip to main content

Formula Context Object

Every formula function receives a single info parameter containing the following properties:
Formula Execution TimingFormulas are evaluated from the document’s data — when the document is opened or reloaded, when a row is created or edited, and when Check stored formulas runs — not during cell rendering. Since v26.7.1 a formula therefore runs whether or not its column is visible in the current view. When a formula result differs from the stored value, Risksheet can mark the item as edited; writing the result back to Polarion respects the readOnly column setting.

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

Formulas on Read-Only ColumnsWhen 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
Numeric Summation vs. Unique CollectionUse 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):
Enum IDs vs. Display NamesFormula 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

Since v26.7.1, formulas are evaluated from the document’s data rather than during cell rendering, so a formula runs whether or not its column is visible in the current view. The columns a formula reads may be hidden as well, and a formula that reads another formula’s column resolves correctly when both are hidden. Other formulas and cell decorators that depend on a hidden column therefore read its computed value, not a stale or null one. Any saved view is safe as the default view, including an export-only layout that hides every formula column.
Storing a Value Has Different TriggersA calculated value reaches the bound Polarion field only for columns with readOnly: false, and only when the document is saved — covering rows that were created or edited, or that Check stored formulas marked as drifted. Opening a document recalculates and displays values without writing them back. See Formulas and Column Visibility for the full rule and for the behavior on versions earlier than v26.7.1.

Check Stored Formulas

Available since v24.5.1 When items are edited outside Risksheet (for example, through Polarion’s standard work item editor, an import, or the API), values stored in Polarion may drift from formula-calculated results. This action reconciles a whole document in one pass. To run it:
  1. Open the Risksheet document. The action requires a clean starting point — save or discard any unsaved changes first.
  2. Navigate to Menu > Rows > Check stored formulas
  3. Risksheet recalculates every formula column for every row and marks each row whose stored value differs as changed
  4. Save the document — the save writes the corrected values to Polarion
The active view does not matter — every configured formula column is covered whether or not it is shown.
Formula-Permission InteractionFormula-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.