Skip to main content

Default Context Menu Actions

When you right-click a cell in the Risksheet grid, the context menu displays built-in actions depending on the cell context and grid state:
ActionWhen AvailableDescription
Open Row ItemAlwaysOpens the current row’s work item in Polarion’s item editor
Open Linked ItemCell contains a valid item linkNavigates to a linked work item from an itemLink column
Open Task ItemCell contains a task linkOpens the task work item; label uses dataTypes.task.name if configured
New [Level] ItemEditable grid, showInMenu: trueCreates a new work item at the selected hierarchy level
Overwrite Row ItemItem has systemReferenceType: "reference"Converts a referenced item to overwrite mode for local editing
Remove Row ItemNon-read-only gridRemoves the selected row from the grid
Freeze PaneAlwaysFreezes columns to the left of the current column
Unfreeze PaneColumns are frozen (frozenColumns > 0)Removes column freezing
DebugappConfig.debug: trueOutputs cell diagnostic info to the browser console
diagram

Register Custom Context Menu Actions

Risksheet exposes an extensibility point through window.risksheet.customContextMenuActions that allows external scripts to register additional menu items.

Step 1 — Define Action Functions

Create JavaScript functions on the global window object. Each custom action needs an enable function (controls when the item is active) and an execute function (runs when clicked):
// Enable function: receives the current row item, returns boolean
window.isReportEnabled = function(item) {
  return item && item.type === "risk";
};

// Execute function: receives the current row item
window.generateRiskReport = function(item) {
  alert("Generating report for: " + item.title);
};

window.isCopyEnabled = function(item) {
  return item !== null;
};

window.copyItemToClipboard = function(item) {
  navigator.clipboard.writeText(item.id + ": " + item.title);
};

Step 2 — Register the Actions

Add your custom actions to the customContextMenuActions array:
window.risksheet = window.risksheet || {};
window.risksheet.customContextMenuActions = [
  {
    label: "Generate Risk Report",
    enableFn: "isReportEnabled",
    executeFn: "generateRiskReport"
  },
  {
    label: "Copy to Clipboard",
    enableFn: "isCopyEnabled",
    executeFn: "copyItemToClipboard"
  }
];
Each custom action object requires three properties:
PropertyTypeDescription
labelstringText displayed in the context menu
enableFnstringName of a window function that returns true to enable the action
executeFnstringName of a window function that runs when the action is clicked

Step 3 — Load the Script

Place the script in your risksheetTopPanel.vm Velocity template so it loads when Risksheet initializes:
<script>
  // Define functions and register actions here
  window.risksheet = window.risksheet || {};
  window.risksheet.customContextMenuActions = [ /* ... */ ];
</script>
Both enableFn and executeFn reference function names as strings. Functions defined inside closures or module scopes will not be found at runtime and the menu action will silently fail.

Control New Item Menu Options

The “New [Level] Item” menu options are generated dynamically from the levels configuration in risksheet.json. Use showInMenu to control which levels appear:
{
  "levels": [
    {
      "name": "Failure Mode",
      "type": "failureMode",
      "showInMenu": true,
      "controlColumn": "systemItemId"
    },
    {
      "name": "Cause",
      "type": "cause",
      "showInMenu": true
    },
    {
      "name": "Internal Reference",
      "type": "reference",
      "showInMenu": false
    }
  ]
}
Setting showInMenu to false hides that level from the context menu while keeping it functional in the grid hierarchy. This is useful for levels populated automatically or through imports.

Customize Task Menu Labels

The “Open Task Item” menu label dynamically reflects the configured task type name. Set dataTypes.task.name in your risksheet.json:
{
  "dataTypes": {
    "task": {
      "name": "Mitigation Action",
      "type": "mitigationAction",
      "role": "mitigates"
    }
  }
}
With this configuration, the context menu displays “Open Mitigation Action” instead of the default “Open Task”.

Overwrite Row Item

The “Overwrite Row Item” action converts a referenced item to overwrite mode, enabling local modifications to be saved back to the source. This action appears only when the selected item has systemReferenceType set to reference.
Enable debug: true in your configuration to add a Debug action to the context menu. It logs the ghost status, column ID, cell value, full item object, and comparison manager state to the browser console — invaluable when diagnosing why an overwrite action is unavailable.
Custom context menu actions for triggering document workflow transitions (e.g., changing document status from within Risksheet) are not natively supported as built-in menu items. Use the customContextMenuActions extensibility point to call the workflow action servlet endpoint from your custom function.

Verify Your Changes

After configuring custom context menu actions:
  1. Reload the Risksheet page to load your script changes
  2. Right-click on a grid cell — you should now see your custom menu items alongside the built-in actions
  3. Verify that the enableFn condition correctly enables/disables the action based on the selected item
  4. Check the browser console for errors if a custom action does not appear

See Also


Support TicketsSource Code
  • RiskSheetContextMenu.ts
  • RisksheetProjectProperties.java
  • ShowConfigurationCommand.ts
  • PolarionAppConfigManager.java
  • WorkflowActionServlet.java