Basic Formula Structure
Formulas are JavaScript function declarations or arrow functions that receive aninfo parameter object:
Formula Parameter: info Object
Every formula receives a single parameter object info that provides access to row data and grid context:
| Property | Type | Description | Example |
|---|---|---|---|
info.item | object | Key-value object containing all column data for the current row. Access values via column binding name. | info.item['severity'], info.item['status'] |
info.cell | HTMLElement | Reference to the DOM element rendering this cell. Used with cell decorators for styling, not typical in formulas. | $(info.cell).toggleClass('highlight') |
info.row | number | Zero-based row index in the grid | info.row → 0, 1, 2, … |
info.col | number | Zero-based column index in the grid | info.col → 0, 1, 2, … |
Accessing Row Data
Use the column binding name (not header) to access cell values:Return Value Conventions
Formula return values must match the column type:| Column Type | Expected Return | Notes |
|---|---|---|
int | number | Integer value; RISKSHEET rounds decimals |
float | number | Decimal number with precision preserved |
string | string | Text value; null renders as empty |
date | Date object or string | Use new Date() or YYYY-MM-DD format |
boolean | boolean | true or false |
enum | string | Must match enum option ID, not label |
| any type | null | Represents empty cell; prevents errors |
Null vs Undefined
Always returnnull for empty values, not undefined:
Operators and Expressions
Formulas support standard JavaScript operators:Arithmetic Operators
Comparison Operators
Logical Operators
Conditional (Ternary) Operator
Common Formula Patterns
Safe Access with Fallback
Conditional Calculation
Chained Calculations
String Concatenation
Type Conversion
Formula Configuration in risksheet.json
Inline Formula Definition
Store short formulas directly in the JSON:Top Panel Formula Definition
For complex logic, define formulas in the Top Panel and reference them:<script> section:
Executing Formulas
When Formulas Execute
Formula Execution Context
Formulas execute in the browser, not on the server:- Access is immediate (no network latency)
- Calculations use current grid state
- All JavaScript features are available (Math, String, Date, etc.)
- Performance depends on formula complexity and number of rows
Formula Scope and Variables
Formulas are isolated functions with their own scope:Error Handling
Formulas should gracefully handle missing or invalid data:- RISKSHEET displays an error indicator in the cell
- The error message appears in browser console
- Other formulas continue executing
- The cell remains empty until the formula is fixed
Syntax Diagram
| Syntax Pattern | Example | Description |
|---|---|---|
| Function Declaration | function(info) { ... return value; } | Standard function with explicit return |
| Arrow Function | (info) => { ... return value; } | Arrow syntax with explicit return |
| Inline Arrow | (info) => expression | Concise single-expression form |
| Accessing Data | info.item['columnBinding'] | Access work item field values |
| Row/Column Context | info.row, info.col | Access row and column metadata |
| Return Value | Must match column type | Return null for empty cells |
Special Characters in Bindings
If column binding contains special characters, use bracket notation:['binding'] instead of dot notation for safety.
For detailed function library and examples, see Formula Functions and Formula Examples.
Sources
Sources
KB ArticlesSource Code
AppConfig.tsrisksheet.jsonAppConfigHelper.tsCellPreviewFormatter.tsPolarionAppConfigManager.java