Context Object Structure
The context object is a hierarchical namespace that Powersheet populates at runtime. Different properties become available depending on where the expression is evaluated.Context Properties Reference
Two Expression Notations
Powersheet uses two distinct notations for dynamic expressions, each tied to a specific configuration context.Context Expression ($context)
Context expressions use dot-notation to access properties from the runtime context. They are used exclusively in data model constraint definitions. No JavaScript logic is supported --- only direct property access.
Where it is used:
domainModelTypes.*.constraints--- entity type constraintsrelationships.*.direct.constraints/relationships.*.back.constraints--- relationship constraints
$context paths:
Dynamic constraints with
$context are evaluated per-row. Different rows can produce different constraint values depending on their source entity’s properties.Dynamic Value (() => expression)
Dynamic values use JavaScript arrow function syntax and are evaluated in sheet configuration contexts. They receive the context object and offer full JavaScript expressiveness for computing values, filtering data, and rendering content at runtime.
Where it is used:
Context Availability Reference
Not all context properties are available in every expression location. The following reference shows which properties are accessible where:Document Context
Powersheet automatically provides document context information to queries and expressions. When a sheet is embedded in a Polarion LiveDoc, thecontext.document properties are populated from the hosting document. The two most commonly used properties in dynamic where clauses are context.document.moduleName and context.document.moduleFolder, which identify the hosting document by name and folder path.
Document Scoping in Constraints
TheapplyCurrentDocumentTo constraint property controls whether queries are automatically filtered to the current document:
applyCurrentDocumentTo matches the query’s from entity type, the query engine injects predicates for document.moduleFolder and document.moduleName to restrict results to items within the current document.
Document ID in Dynamic Expressions
The document ID is available ascontext.document.id in dynamic value expressions and as a query parameter for server-side resolution:
Project Scoping
All queries executed through Powersheet are automatically scoped to the current Polarion project. The query engine adds aproject.id filter to every Lucene query, ensuring results only include entities from the active project. This scoping is applied transparently and does not require explicit configuration.
Dynamic Value Examples
Filtering by Current Document (Module Name)
The most common dynamicwhere clause restricts a query to items in the hosting LiveDoc. Use context.document.moduleName to match the document by name:
moduleName with moduleFolder:
Using column.display for Document and Chapter References
The column.display option is the standard way to control how a navigation property is rendered in a cell. For document references, display: titleOrName renders the document’s title when available and falls back to the module name:
display: title renders the chapter heading text:
Filtering by Date
Dynamic date calculations use JavaScript date functions. The resulting value must match the data type format --- for dates, use.toISOString():
Setting Initial Values for New Entities
TheentityFactory property sets default values when creating new work items. The factory re-evaluates dynamically based on the parent entity, so context-sensitive defaults are typically derived from context.source:
Calculated Column Values
Theformula property computes a value from other properties on the current entity:
Custom Cell Rendering
Therender property and named renderers produce custom HTML output:
Display Override for Navigation Properties
When the standarddisplay: titleOrName / display: title shorthands are not sufficient, the display property accepts a dynamic expression that overrides what is shown for a linked entity column:
Conditional Formatting
Formatter expressions use a simplified syntax without the() => prefix. The expression is evaluated as a boolean condition:
Formatter expressions do not start with
() =>. They are evaluated directly as boolean conditions against the context object.Context Expression Examples (Data Model)
Filter by Source Document Component
Restrict linked items to the same document component as the source entity:SystemRequirement from the “Braking” component, only DesignRequirement items from “Braking” documents are loaded.
Filter by Source Document Identity
Restrict to the exact same document as the source entity:Filter by Source Document Type
Restrict picker results to documents of the same type as the source entity’s document:Quick Reference
Related Pages
- EntityQuery --- query construction and execution
- Predicates --- filtering operators for
whereclauses - Expand Clause --- loading related entities in queries
- Document Filtering --- document-scoping mechanisms
- Baseline and Revision Queries --- querying historical data
- Dynamic Value Expressions Reference --- complete dynamic expression syntax
- Context Expressions Reference ---
$contextpath reference for data models - Constraints --- constraint configuration including stages and operators
- Columns --- column-level configuration for
formula,render, anddisplay - Formatters --- conditional formatting with expression syntax