PolarionContext¶
The object returned by fetchContext(), field by field.
interface PolarionContext {
applicationId: string;
viewId: string;
projectId?: string;
spaceId?: string;
documentId?: string;
workItemId?: string;
selectedWorkItemIds: string[];
appEndpoint: string;
restBaseUrl: string;
restToken?: string;
}
Fields¶
applicationId¶
The identifier from the manifest of the application that owns the view. Always set.
viewId¶
The identifier of the view (from views.*[].identifier). Always set. Together with applicationId it tells a shared code base which view is running.
projectId¶
Id of the project the view is shown in, for example "test". Set for all view types inside a project. Undefined only in places without a project context (none of the three view types in 2612 are placed outside a project).
spaceId, documentId¶
Space and name of the Document, set (according to the SDK documentation) when the view is shown inside a Document: a sidebar opened in the Document editor, or a form extension in a work item form opened from a Document. Undefined elsewhere. Use them to build the REST URL …/projects/{projectId}/spaces/{spaceId}/documents/{documentId}.
workItemId¶
Project-local id of the work item whose form contains the view, for example "TEST-514". Set for form extensions. Undefined for sidebars and navigation topics, and in the create form of a work item that is not saved yet.
selectedWorkItemIds¶
Array of work item ids with the project, for example "test/TEST-514". Always present, possibly empty.
| View type | Content |
|---|---|
| Form extension | The open work item, ["<projectId>/<workItemId>"]. In the multi-item edit form below the Work Items table: all ticked items, while workItemId is the current one. |
| Sidebar | Empty on Polarion 2612, even when rows are selected. The selection arrives through selection-changed events. |
| Navigation topic | Empty. |
appEndpoint¶
Absolute base URL of the application's server-script endpoints, without trailing slash:
https://<host>/polarion/apps/<applicationId>/rest
Append /<urlPath> for each endpoint declared in the manifest. Set even when the application declares no endpoints.
restBaseUrl¶
Absolute base URL of the Polarion REST API, without trailing slash:
https://<host>/polarion/rest/v1
restToken¶
Token that authenticates REST and endpoint calls as the current user. Send it in the required X-Polarion-REST-Token header on every REST and endpoint call. Application endpoints cannot authenticate through the browser session or cookies. Undefined or empty when the server has not enabled REST token authentication (com.siemens.polarion.rest.security.restApiToken.enabled). Treat it as a credential: memory only, same origin only.
Example values¶
Form extension on a Task:
{
"applicationId": "com.example.context",
"viewId": "form",
"projectId": "test",
"workItemId": "TEST-514",
"selectedWorkItemIds": ["test/TEST-514"],
"appEndpoint": "https://polarion.example.com/polarion/apps/com.example.context/rest",
"restBaseUrl": "https://polarion.example.com/polarion/rest/v1",
"restToken": "UE9M…"
}
Sidebar in the Work Items table with two rows selected (the selection comes through events, not here):
{
"applicationId": "com.example.selectionsidebar",
"viewId": "selection",
"projectId": "test",
"selectedWorkItemIds": [],
"appEndpoint": "https://polarion.example.com/polarion/apps/com.example.selectionsidebar/rest",
"restBaseUrl": "https://polarion.example.com/polarion/rest/v1",
"restToken": "UE9M…"
}
Navigation topic:
{
"applicationId": "com.example.dashboard",
"viewId": "dashboard",
"projectId": "test",
"selectedWorkItemIds": [],
"appEndpoint": "https://polarion.example.com/polarion/apps/com.example.dashboard/rest",
"restBaseUrl": "https://polarion.example.com/polarion/rest/v1",
"restToken": "UE9M…"
}
Validation performed by the SDK¶
fetchContext() only checks that applicationId and viewId are strings. All other fields are passed through as delivered by the host. Code defensively against undefined optional fields.