Skip to main content
See also: Constraints | Properties | Relationships | Binding Syntax

Two Expression Notations

Powersheet uses two distinct expression notations depending on the configuration layer: diagram
NotationSyntaxUsed InExpressiveness
Context expression$context.property.pathDomain model configuration (constraints)Dot-notation property access only
Dynamic value() => expressionSheet configuration (where, formula, render, etc.)Full JavaScript arrow function
If you are editing a domain model YAML file (domainModelTypes, relationships), use $context. If you are editing a sheet configuration YAML file (sources, columns, formatters), use () =>.

Context Expression ($context)

Context expressions use dot-notation to access properties from the runtime context. They are used exclusively in domain model configuration — specifically within constraint definitions on entity types and relationships.

How It Works

A $context expression is a property path that Powersheet resolves by traversing the context object at runtime. No JavaScript logic is supported — only direct property access via dot-separated keys.

Where It Is Used

Configuration LocationDescription
domainModelTypes.*.constraintsEntity type constraints — scopes load, pick, or create stages
relationships.*.direct.constraintsDirect-direction relationship constraints
relationships.*.back.constraintsBack-direction relationship constraints

Available Context Paths

PathTypeDescriptionExample Value
$context.source.typestringSource entity’s Polarion work item type"sys_req"
$context.source.document.idstringSource entity’s document ID"Requirements/SRS"
$context.source.document.moduleNamestringSource entity’s document module name"UserNeedSpecification"
$context.source.document.moduleFolderstringSource entity’s document folder path"Requirements"
$context.source.document.componentstringSource entity’s document component"Braking"
$context.source.document.typestringSource entity’s document type"systemRequirementsSpecification"
$context.source.document.titlestringSource entity’s document title"System Requirements"
Dynamic constraints with $context are evaluated per-row. Different rows can produce different constraint values depending on their source entity’s properties. For example, a UserNeed in a “Braking” document produces different constraint values than one in a “Steering” document.

Context Expression Examples

Filter linked items to the same document component as the source item:
relationships:
  - from: DesignRequirement
    to: SystemRequirement
    back:
      name: designRequirements
      constraints:
        load:
          document:
            component: $context.source.document.component
When viewing a SystemRequirement from the “Braking” component, only DesignRequirement entities from “Braking” documents are loaded. Filter linked items to the same document as the source item:
constraints:
  load:
    document:
      moduleName: $context.source.document.moduleName
      moduleFolder: $context.source.document.moduleFolder
This restricts loaded entities to the exact same LiveDoc document as the source entity, matching on both module name and folder. Filter picker options by source document type:
constraints:
  pick:
    document:
      type: $context.source.document.type
When a user opens a picker dialog, only entities from documents matching the source entity’s document type appear as options.

Complete Domain Model Example with Context Expressions

domainModelTypes:
  UserNeed:
    polarionType: user_need
    properties:
      description:
      severity:

  SystemRequirement:
    polarionType: sys_req
    properties:
      description:
      severity:

  DesignRequirement:
    polarionType: des_req
    properties:
      description:

relationships:
  - from: SystemRequirement
    to: UserNeed
    cardinality: many-to-many
    storage: linkedWorkItems
    linkRole: decomposes
    direct:
      name: userNeeds
    back:
      name: systemRequirements
      constraints:
        load:
          document:
            component: $context.source.document.component

  - from: DesignRequirement
    to: SystemRequirement
    cardinality: many-to-many
    storage: linkedWorkItems
    linkRole: decomposes
    direct:
      name: systemRequirements
    back:
      name: designRequirements
      constraints:
        load:
          document:
            moduleName: $context.source.document.moduleName
            moduleFolder: $context.source.document.moduleFolder
        pick:
          document:
            type: $context.source.document.type
In this model, SystemRequirement back-navigation to DesignRequirement entities filters by both module name and folder at load time, and additionally restricts picker results by document type.

Dynamic Value (() => expression)

Dynamic values use JavaScript arrow function syntax and are used in sheet configuration YAML files. They provide full JavaScript expressiveness for computing values, filtering data, and rendering content at runtime.

How It Works

A () => expression is a JavaScript arrow function that receives a context object. Powersheet evaluates the function at runtime and uses the returned value. The expression must be wrapped in quotes within the YAML to preserve the arrow function syntax.

Where It Is Used

Sheet Configuration PropertyPurposeReturns
sources.query.whereFilter data with dynamic predicatesValue matching the predicate type
sources.entityFactorySet initial values for new itemsProperty value
columns.*.formulaCalculate column values from other propertiesComputed value (persisted)
columns.*.renderCustom HTML rendering for cellsHTML string
columns.*.displayOverride display value for navigation propertiesDisplay string
renderers.*Named renderer definitionsHTML string
formatters.*.expressionConditional formatting expressionsBoolean
formula affects persisted data — the calculated value is saved back to the data source. Use render if you only need to change how a value is displayed without modifying the underlying data.
Formatter expressions use a simplified syntax — they do not start with () =>. The expression is evaluated as a boolean condition directly (e.g., "context.item.Probability <= 99").

Context Availability by Location

Not all context properties are available in every location. The following table shows which context sub-objects are accessible in each usage location:
Usage Location.user.sources.document.item.value.source.entity.parameters
where
entityFactory
formula
render / renderers
formatter
display

Dynamic Value Examples

Where clause — filter by URL parameter:
sources:
  - id: opportunities
    query:
      from: Opportunity
      where:
        Client:
          "==": "() => context.parameters.client"
The sheet loads only Opportunity entities whose Client field matches the client URL parameter value. Where clause — filter by today’s date:
where:
  DueDate:
    ">": "() => new Date().toISOString()"
The resulting value must be in the correct format for the data type. For date fields, use .toISOString() to produce the ISO 8601 string that Polarion expects.
Where clause — combine multiple parameters:
where:
  Client:
    "==": "() => `${context.parameters.client} ${context.parameters.status}`"
Template literal syntax allows concatenating multiple URL parameters into a single filter value. Entity factory — set initial value from a URL parameter:
sources:
  - id: user_needs
    query:
      from: UserNeed
    entityFactory:
      Client: "() => context.parameters.client"
When a user creates a new UserNeed entity in this sheet, the Client field is automatically populated with the value of the client URL parameter. Formula — calculate a value from other item properties:
columns:
  totalPrice:
    formula: "() => context.item.quantity * context.item.unitPrice"
The totalPrice column value is computed by multiplying quantity by unitPrice. This calculated value is persisted to the data source. Renderer — custom HTML output:
renderers:
  linkedItems: "() => context.value.map((item) => `<b>${item.name}</b>`).join(', ')"
Renders each linked item name in bold, separated by commas. Display — show a property of a linked entity:
columns:
  systemRequirement.document:
    display: "() => context.document.title"
Instead of showing the raw document reference, the column displays the document’s human-readable title. Formatter — conditional styling:
formatters:
  criticalHighlight:
    expression: "context.item.Probability <= 99"
    style: warningStyle
Applies warningStyle to cells where the Probability value is 99 or below. Note the simplified syntax without () =>.

The Context Object

The context object provides runtime information to dynamic expressions. Its structure is hierarchical, with properties progressively available depending on the evaluation scope.

Context Object Structure

PropertyTypeDescriptionAvailable In
context.parametersobjectURL and configuration parameters as key-value pairs. Access individual parameters via context.parameters.{paramName}.where, entityFactory, formula
context.parameters.{paramName}stringIndividual URL parameter value (e.g., context.parameters.client)where, entityFactory, formula
context.userobjectCurrent logged-in Polarion userwhere, entityFactory, formula
context.user.idstringUser’s login IDwhere, entityFactory, formula
context.user.namestringUser’s display namewhere, entityFactory, formula
context.sourcesobjectAll configured data source definitions from the sheet configurationwhere, entityFactory, formula
context.documentobjectCurrent document informationwhere, formatter
context.document.titlestringDocument titlewhere, formatter
context.document.typestringDocument typewhere, formatter
context.document.idstringDocument identifierwhere, formatter
context.document.moduleNamestringDocument module namewhere, formatter
context.document.moduleFolderstringDocument folder pathwhere, formatter
context.document.componentstringDocument componentwhere, formatter
context.toolobjectCurrent tool informationSee application
context.tool.typestringTool type identifierSee application
context.itemobjectCurrent entity (row) with all its properties. Access fields via context.item.{propertyName}.formula, render, formatter, display
context.sourceobjectParent/source entity in relationship contexts. Access its document via context.source.document.*.formula, display, $context expressions
context.entityobjectCurrent entity as a plain objectformula
context.valueanyCurrent cell’s display valueformula, render, formatter, display

Context Tree Diagram

context
 +-- parameters          URL and configuration parameters (key-value pairs)
 |    +-- {paramName}     e.g., context.parameters.client
 +-- user                Current logged-in user
 |    +-- id
 |    +-- name
 +-- sources             All configured data source definitions
 +-- document            Current document information
 |    +-- title
 |    +-- type
 |    +-- id
 |    +-- moduleName
 |    +-- moduleFolder
 |    +-- component
 +-- tool                Current tool information
 |    +-- type
 +-- item                Current entity (per-cell contexts only)
 |    +-- {propertyName}  e.g., context.item.StoryPoints
 +-- source              Parent/source entity (relationship contexts)
 |    +-- {propertyName}  e.g., context.source.document.component
 +-- entity              Current entity as a plain object
 +-- value               Current cell's display value
  • item, source, entity, and value are only available in per-cell contexts (formula, render, formatter, display)
  • document is available in where clauses and formatter expressions
  • In $context expressions (domain model constraints), only source and its sub-properties are available

Notation Comparison

The two expression systems serve complementary purposes. Understanding when to use each prevents configuration errors.
Aspect$context (Model)() => (Sheet)
Syntax$context.source.document.component"() => context.parameters.client"
LanguageDot-notation path (no logic)JavaScript arrow function
Configuration fileDomain model YAMLSheet configuration YAML
EvaluationPer-row, based on source entityPer-cell or per-query, based on context scope
CapabilitiesProperty path access onlyArithmetic, string interpolation, array methods, conditionals
Use casesConstraint scoping by document, type, componentQuery filtering, calculated columns, custom rendering
YAML quotingNot requiredRequired (wrap in double quotes)

Quick Reference

I want to…NotationExample
Filter relationship by source document component$contextcomponent: $context.source.document.component
Filter relationship by source document module$contextmoduleName: $context.source.document.moduleName
Filter query by URL parameter() =>"==": "() => context.parameters.client"
Calculate column from other fields() =>formula: "() => context.item.qty * context.item.price"
Render custom HTML in a cell() =>render: "() => '<b>' + context.value + '</b>'"
Set default value for new items() =>entityFactory: { Client: "() => context.parameters.client" }
Conditionally style a cellexpressionexpression: "context.item.Risk > 50"
Filter by today’s date() =>">": "() => new Date().toISOString()"
Show linked entity property() =>display: "() => context.document.title"

Complete Sheet Configuration Example

The following example demonstrates multiple dynamic value expression types in a single sheet configuration:
sources:
  - id: opportunities
    query:
      from: Opportunity
      where:
        Client:
          "==": "() => context.parameters.client"
        DueDate:
          ">": "() => new Date().toISOString()"
    entityFactory:
      Client: "() => context.parameters.client"

columns:
  title:
    title: Title
    hasFocus: true
  Client:
    title: Client
    isReadOnly: true
  quantity:
    title: Quantity
  unitPrice:
    title: Unit Price
  totalPrice:
    title: Total Price
    formula: "() => context.item.quantity * context.item.unitPrice"
    isReadOnly: true
  systemRequirement.document:
    display: "() => context.document.title"

renderers:
  linkedItems: "() => context.value.map((item) => `<b>${item.name}</b>`).join(', ')"

formatters:
  criticalHighlight:
    expression: "context.item.Probability <= 99"
    style: warningStyle
This configuration:
  1. Filters the Opportunity source by URL parameter client and future due dates
  2. Pre-fills the Client field on new entities from the URL parameter
  3. Calculates totalPrice from quantity and unitPrice (persisted)
  4. Displays the document title instead of a raw reference
  5. Renders linked items with bold formatting
  6. Highlights rows where Probability is 99 or below

See Also

  • Constraints — full reference on constraint configuration including stages, operators, and composition
  • Columns — column configuration properties including formula, render, and display
  • Formatters — conditional formatting and style definitions
  • Sources — source query configuration including where and entityFactory
  • Binding Syntax — dot-notation paths for column keys
  • Navigation Directions — direct and back relationship directions
  • Cardinality — how relationship cardinality affects expand patterns and column binding
Authoritative reference: Dynamic Value Expressions (Confluence) — complete specification of both expression notations, context object structure, and availability matrix. Model-Source-Columns Cardinality Reference (Confluence) — relationship cardinality patterns including constraint examples.