In some workflows, you may want to control whether an upstream item (e.g., a Hazard) can be linked to a Risk, based on the value of a custom field in the Risk item.
Using the cellDecorators feature in the Risksheet configuration, you can dynamically enable or disable linking based on logic tied to field values.
TABLE OF CONTENTS
Configuration
You have a custom field in the Risk item, titled “Link Hazards? Yes/No” (with field ID: loadHazard).
- If the value is "Yes", allow the user to link Hazards to the Risk
- If the value is not "Yes", make the Hazard link column read-only in the Risksheet.
Step 1: Add a Cell Decorator
Include the following snippet in the cellDecorators section of your Risksheet configuration:
...
"cellDecorators": {
"hazard": "function(info){if(info.item.loadHazard!=='Yes'){ info.item.systemReadOnlyFields=info.item.systemReadOnlyFields+'|hazard|';$(info.cell).toggleClass('creadonly',true);}}"
}
...
This function checks if loadHazard is not 'yes'.
If not, it marks the hazard field as read-only and applies a visual style "creadonly".
Step 2: Use the Decorator in the Column Definition
In the RiskSheet column definition where Hazards are linked, reference the decorator using "cellRenderer":
..
"header": "Potential Failure Mode",
"type": "itemLink",
"id": "hazard",
"cellRenderer":"hazard",
...
As a result, only Risk items with “Link Hazards?” = "Yes", will have an editable cell for linking Hazards in the Risksheet.
Otherwise, the cell will be read-only and visually styled to indicate that editing is not allowed.
For any assistance, please don’t hesitate to reach out by submitting a ticket here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article