Skip to main content

Use Case

You want to control whether users can link upstream items (like Hazards) to a Risk based on a custom field value. For example, a “Link Hazards?” field set to “Yes” enables linking, while “No” makes the link column read-only.

Configuration Steps

Step 1: Add a Control Field

First, ensure you have an enum field in Polarion that will control linking behavior. For this example, we’ll use a field called loadHazard with values “Yes” and “No”.

Step 2: Create a Cell Decorator

Add a cell decorator function in the cellDecorators section of your risksheet.json configuration:
"cellDecorators": {
  "hazard": "function(info){if(info.item.loadHazard!=='Yes'){ info.item.systemReadOnlyFields=info.item.systemReadOnlyFields+'|hazard|';$(info.cell).toggleClass('creadonly',true);}}"
}
How this works: diagram The decorator:
  • Checks if loadHazard field is not “Yes”
  • Appends the column ID (hazard) to systemReadOnlyFields to mark it read-only
  • Applies the creadonly CSS class for visual indication

Step 3: Apply the Decorator to Your Column

Reference the decorator in your item link column definition using the cellRenderer property:
{
  "header": "Potential Failure Mode",
  "type": "itemLink",
  "id": "hazard",
  "cellRenderer": "hazard",
  "bindings": "hazard.title",
  "typeProperties": {
    "linkRole": "assessedHazard",
    "linkTypes": "hazard"
  },
  "level": 1
}
The decorator function name ("hazard") and the cellRenderer value must exactly match the column’s id property for the decorator to be applied correctly.

Step 4: Add Visual Styling (Optional)

Define CSS styling for the creadonly class to visually indicate read-only cells:
"styles": {
  ".creadonly": {
    "background-color": "#f5f5f5 !important",
    "color": "#999 !important",
    "cursor": "not-allowed"
  }
}

Advanced Patterns

Multiple Conditions

You can combine multiple field checks:
function(info){
  if(info.item.status !== 'draft' || info.item.approved === 'Yes'){
    info.item.systemReadOnlyFields = info.item.systemReadOnlyFields + '|hazard|';
    $(info.cell).toggleClass('creadonly', true);
  }
}

Conditional Visibility

To hide cells completely instead of making them read-only:
function(info){
  if(info.item.loadHazard !== 'Yes'){
    $(info.cell).hide();
  }
}
If you want to filter which items can be linked (rather than enabling/disabling the entire column), use the queryFactory approach described in Configure Dropdown Categories.

Common Pitfalls

Enum comparisons are case-sensitive. Ensure you match the exact enum option ID, not the display label. Use info.item.fieldId === 'optionId', not === 'Option Label'.
System fields like id, type, and status are always read-only and cannot be controlled via cell decorators.

Verification

After applying this configuration:
  1. Reload your RISKSHEET to apply the new decorator
  2. Open a Risk item where the control field is set to “No”
  3. Click the link column cell — it should appear grayed out and not editable
  4. Change the control field to “Yes” and save
  5. Refresh the view — the link column should now be editable
You should now see conditional linking behavior based on your control field value, with visual feedback indicating when cells are read-only.

See Also