> ## 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.

# Velocity Server Rendering

> Nextedy POWERSHEET server-rendered properties support Velocity template expressions that execute on the Polarion server.

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>;
};

## Server Rendering Context

When a property is configured with `serverRender`, the server evaluates the expression using Velocity templates with automatically injected Polarion services. These services are available as context variables in all server-rendered expressions.

### Injected Polarion Services

| Service Variable     | Purpose                     | Common Use Cases                                                                 |
| -------------------- | --------------------------- | -------------------------------------------------------------------------------- |
| `$trackerService`    | Access work item data       | Querying work items, running Lucene queries, accessing tracker metadata          |
| `$txService`         | Transaction management      | Understanding execution context, managing Polarion transactions                  |
| `$repositoryService` | Repository-level operations | Accessing project metadata, users, roles, repository configuration               |
| `$securityService`   | Permission checking         | Checking user permissions, role-based visibility, enforcing security constraints |

<Tip title="All Services Are Auto-Injected">
  These services are automatically available in every server-rendered expression. No additional configuration is required to access them.
</Tip>

## Server-Rendered Property Configuration

Properties configured with `serverRender` in the data model are evaluated on the server before being sent to the client. This affects both how the property value is computed and its editability.

### Property Definition

| Name              | Type      | Default         | Description                                                                             |
| ----------------- | --------- | --------------- | --------------------------------------------------------------------------------------- |
| `name`            | `string`  | Required        | Property name exposed in the Powersheet client                                          |
| `serverName`      | `string`  | Same as `name`  | Override for the actual Polarion field name when it differs from the client-facing name |
| `customFieldName` | `string`  | `null`          | Polarion custom field ID for properties stored in custom fields                         |
| `type`            | `string`  | See application | Data type of the property (`string`, `integer`, `date`, `enum`, etc.)                   |
| `storage`         | `string`  | See application | How the property value is persisted in Polarion                                         |
| `readable`        | `boolean` | `true`          | Controls whether the property can be read by clients                                    |
| `updatable`       | `boolean` | `true`          | Controls whether the property can be modified by clients                                |
| `scalar`          | `boolean` | `true`          | Whether property holds a single value (`true`) or collection (`false`)                  |

<Warning title="Server-Rendered Fields Are Read-Only">
  Properties with `serverRender` enabled are automatically marked as non-editable in the sheet, regardless of the `updatable` setting. The server computes the value on each query; client-side edits would be overwritten.
</Warning>

## Velocity Template Context Variables

Server-rendered expressions have access to these context variables during template execution:

| Variable   | Description                                                   |
| ---------- | ------------------------------------------------------------- |
| `$item`    | The current work item being rendered                          |
| `$tx`      | The current transaction context                               |
| `$context` | The query context including project, document, and parameters |
| `$pObject` | The Polarion persistent object reference                      |

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

## Service Usage Patterns

### Tracker Service

Use `$trackerService` to query work items, access tracker metadata, and run Lucene queries within server-rendered expressions.

```velocity theme={null}
$trackerService.queryWorkItems("project.id:myProject AND type:requirement", "id")
```

### Security Service

Use `$securityService` to implement role-based visibility and conditional content in server-rendered fields.

```velocity theme={null}
#if($securityService.canPerformActionOnWorkItem($item, "modify"))
  editable
#else
  read-only
#end
```

### Repository Service

Use `$repositoryService` to access project metadata, user information, and repository configuration.

```velocity theme={null}
$repositoryService.getProjectByID("myProject").getName()
```

## Security Considerations

Server-rendered properties interact with the Powersheet security model:

| Aspect                  | Behavior                                                                            |
| ----------------------- | ----------------------------------------------------------------------------------- |
| Editability             | Server-rendered fields are always read-only in the client                           |
| Permission inheritance  | Entity-level `readable`/`updatable` settings intersect with property-level settings |
| System read-only fields | `id`, `outlineNumber` are always read-only regardless of configuration              |

<Info title="Verify in application">
  The exact list of available service methods depends on the Polarion server version. Consult the Polarion SDK documentation for the full API reference of each injected service.
</Info>

## Complete YAML Example

```yaml theme={null}
domainModelTypes:
  UserNeed:
    polarionType: userNeed
    properties:
      title:
      severity:
      computedStatus:
        serverRender: |
          #set($linkedItems = $trackerService.queryWorkItems(
            "project.id:$item.projectId AND type:systemRequirement", "id"))
          #if($linkedItems.size() > 0)
            Linked
          #else
            Unlinked
          #end
        readable: true
        updatable: false
  SystemRequirement:
    polarionType: systemRequirement
    properties:
      title:
      priority:
```

## Related Pages

* [Velocity Templates](/powersheet/reference/server-rendering/velocity-templates) -- Template syntax and expression language
* [Context Variables](/powersheet/reference/server-rendering/context-variables) -- All variables available in server rendering context
* [Polarion Services](/powersheet/reference/server-rendering/polarion-services) -- Detailed reference for each injected service
* [Properties](/powersheet/reference/data-model/properties) -- Data model property configuration
* [Permissions](/powersheet/reference/data-model/permissions) -- Security model for properties and entities

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