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
- A data model with a server-rendered property
- A sheet that you open inside a Collection with the
_collectionURL parameter (see Open a Sheet in a Polarion Collection)
1
Read the Collection Id
The template sees the sheet’s URL parameters in Outside a Collection the parameter is absent, and
$context.parameters. Read the Collection id with .get("_collection"):$colId keeps the empty string from the first line.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
- Open the sheet without
_collection. The column shows what it showed before. - 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. - 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
- Collection-Scoped Sheets — what a Collection changes in each part of a sheet
- Context Variables —
$context.parametersand the other variables a template receives - Access Polarion Services —
$trackerServiceand the other platform services - Debug Template Errors — what to check when a cell shows
#SERVER_RENDER_ERROR