Skip to main content
A sheet opened inside a Polarion Collection narrows its rows, expanded levels and pickers to that Collection. A serverRender template is different: whatever it searches for or reads on its own stays project-wide until the template itself asks which Collection the sheet is in. This guide shows how to do that, using a column that lists a work item’s linked items as the example.

Prerequisites

1

Read the Collection Id

The template sees the sheet’s URL parameters in $context.parameters. Read the Collection id with .get("_collection"):
Outside a Collection the parameter is absent, and $colId keeps the empty string from the first line.
Use .get("_collection"), not the dot form$context.parameters._collection does not work. A Velocity name cannot start with an underscore, so the cell shows the reference as literal text instead of the id. The same holds for every URL parameter whose name starts with _.
2

Branch on It

Keep the template’s existing behavior for a sheet opened without a Collection, and add a branch for a sheet opened inside one:
3

Resolve the Collection and Narrow the Read

Inside the Collection branch, resolve the Collection from its id, then use it to decide what the template shows. This example lists the ids of the work items linked from the row. Inside a Collection it keeps only those whose document belongs to the Collection:
$col.getElement(…) returns the Collection’s entry for a document, and nothing when the document is not in the Collection. A linked item that lives in no document, or in a document outside the Collection, is therefore left out. Without a Collection, $col stays false and every linked item is listed, as before.$trackerService is one of the Polarion services available to every template, and $wi is the row’s work item.

Verify

  1. Open the sheet without _collection. The column shows what it showed before.
  2. Open the same sheet with _collection=<id>. The column shows only data from that Collection: in the example, only linked items whose document the Collection contains.
  3. Open it with the id of a second Collection that contains different documents. The column changes with the Collection.

What to Keep in Mind

  • Scoping is opt-in per template. A server-rendered property that does not read the Collection id keeps showing project-wide results inside a Collection. Review each such property before relying on it in a collection-scoped sheet.
  • The id comes from the sheet URL. The template sees a Collection only when the sheet was opened with _collection.
  • The rows are already scoped. The sheet only renders rows the Collection contains. Only what the template fetches on its own needs the steps above.
  • Templates stay read-only. Reading the Collection does not let a template change Polarion data.

See Also