> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Variables

> Nextedy POWERSHEET Velocity templates have access to a set of context variables that provide work item data, document context, and Siemens Polarion ALM platform services.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

## Variable Summary

| Variable   | Type              | Availability             | Description                                                                   |
| ---------- | ----------------- | ------------------------ | ----------------------------------------------------------------------------- |
| `$item`    | ModelObject       | All entities             | Primary work item accessor with property access methods                       |
| `$wi`      | IWorkItem         | Work item entities only  | Legacy Polarion work item API for low-level operations                        |
| `$tx`      | Transaction       | All evaluations          | Current transaction object for query operations                               |
| `$module`  | IModule           | Document-scoped entities | Document (LiveDoc) containing the work item; `null` for non-document entities |
| `$context` | PowersheetContext | All evaluations          | Powersheet-specific context: project, document scope, query helpers           |
| `$pObject` | IPObject          | All entities             | Raw Polarion persistent object                                                |

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/-WiVljKlDztH36bB/powersheet/diagrams/reference/server-rendering/context-variables/diagram-1.svg?fit=max&auto=format&n=-WiVljKlDztH36bB&q=85&s=3a673e5e1dfe0a427be537ce892f6353" alt="diagram" style={{ width: "520px", maxWidth: "100%" }} width="520" height="260" data-path="powersheet/diagrams/reference/server-rendering/context-variables/diagram-1.svg" />
</Frame>

## \$item (ModelObject)

The primary accessor for work item data. Available for all entity types.

| Property / Method | Return Type | Description                       |
| ----------------- | ----------- | --------------------------------- |
| `$item.title`     | `string`    | Work item title                   |
| `$item.status`    | `object`    | Status object with `.id` property |
| `$item.author`    | `object`    | Author user object                |
| `$item.created`   | `datetime`  | Creation timestamp                |
| `$item.updated`   | `datetime`  | Last modification timestamp       |
| `$item.uri`       | `string`    | Polarion URI for the work item    |

### Example

```velocity theme={null}
$item.title - $item.status.id
```

<Tip title="Preferred Variable">
  Use `$item` as the primary work item accessor. It provides a higher-level API than `$wi` and is available for all entity types.
</Tip>

## \$wi (IWorkItem)

Legacy Polarion work item API. Only available when the entity is a work item (not for documents or other entity types).

| Property / Method          | Return Type  | Description                            |
| -------------------------- | ------------ | -------------------------------------- |
| `$wi.getLinkedWorkItems()` | `collection` | Returns all linked work items          |
| `$wi.getCustomField(name)` | `object`     | Returns custom field value by field ID |
| `$wi.getProjectId()`       | `string`     | Returns the project ID                 |

### Example

```velocity theme={null}
#set($links = $wi.getLinkedWorkItems())
$links.size() linked items
```

<Note title="Availability">
  `$wi` is only set for work item entities. For `Document` or other non-work-item entity types, `$wi` is `null`. Use `$item` for cross-entity-type templates.
</Note>

## \$tx (Transaction)

Current transaction object for transactional queries and read-only operations.

| Property / Method | Return Type | Description                                   |
| ----------------- | ----------- | --------------------------------------------- |
| Transaction scope | object      | Access to transaction-scoped data and queries |

### Example

```velocity theme={null}
#set($related = $trackerService.getWorkItemByUri($item.uri))
$related.title
```

<Warning title="Read-Only Operations">
  Server-rendered templates should perform read-only operations only. Modifying data within a template evaluation can cause unexpected side effects.
</Warning>

## \$module (IModule)

The LiveDoc containing the current work item. `null` for entities not within a document.

| Property / Method      | Return Type | Description                |
| ---------------------- | ----------- | -------------------------- |
| `$module.moduleFolder` | `string`    | Document folder/space path |
| `$module.moduleName`   | `string`    | Document name              |
| `$module.space`        | `string`    | Polarion space identifier  |

### Example

```velocity theme={null}
#if($module)
  Document: $module.moduleName in $module.moduleFolder
#else
  No document context
#end
```

<Note title="Null Check Required">
  Always check `#if($module)` before accessing module properties. Entities that are not contained within a document will have `$module` set to `null`.
</Note>

## \$context (PowersheetContext)

Powersheet-specific context providing access to project scope, document scope, and query capabilities.

| Property / Method | Return Type | Description                        |
| ----------------- | ----------- | ---------------------------------- |
| Project context   | object      | Current project information        |
| Document scope    | object      | Current document filtering context |
| Query helpers     | object      | Query execution utilities          |

### Example

```velocity theme={null}
$context.projectId
```

<Info title="Verify in application">
  The exact methods available on `$context` depend on the Powersheet version. Consult the server logs for available context properties.
</Info>

## \$pObject (IPObject)

The raw Polarion persistent object underlying the entity.

| Property / Method    | Return Type | Description                  |
| -------------------- | ----------- | ---------------------------- |
| `$pObject.uri`       | `string`    | Polarion URI                 |
| `$pObject.contextId` | `string`    | Context (project) identifier |

## Client-Side Context Variables

In addition to server-side Velocity variables, Powersheet supports client-side `$context` expressions for dynamic value resolution in YAML configuration.

| Context Path                         | Description                           |
| ------------------------------------ | ------------------------------------- |
| `$context.document.id`               | Current document path (`folder/name`) |
| `$context.source.document.component` | Source entity's document component    |
| `$context.source.project.id`         | Source entity's project ID            |

These are resolved at configuration processing time, not during Velocity template evaluation. See [JavaScript Functions](/powersheet/reference/server-rendering/javascript-functions) for client-side expressions.

## Complete YAML Example

```yaml theme={null}
domainModelTypes:
  UserNeed:
    polarionType: userNeed
    properties:
      title:
      status:
      documentPath:
        serverRender: |
          #if($module)$module.moduleFolder/$module.moduleName#else(unscoped)#end
      authorName:
        serverRender: "$item.author.name"
      linkCount:
        serverRender: |
          #set($links = $wi.getLinkedWorkItems())
          $links.size()
```

## Related Pages

* [Velocity Templates](/powersheet/reference/server-rendering/velocity-templates) -- template syntax and evaluation
* [Polarion Services](/powersheet/reference/server-rendering/polarion-services) -- platform service variables
* [Properties](/powersheet/reference/data-model/properties) -- data model property definitions

***

<LastReviewed date="2026-07-02" />
