Since version 2019 it is possible to annotate a "context" to any CausalityRelation. This feature is for example used by the HARA editor to annotate HazardeousEvents to relations between a Malfunction and a Hazard. This is useful for the overall failure net from top to bottom and also nice as it illustrates that multiple 'HazardeousEvents' may annotate the same relation. However, it also implies that you cannot remove the cause or the effect of the relation (which implies the removal of the relation), without having removed the context before.
This is sometimes an undesired situation and a script to clean up the context is beneficial. Lookup and removal is straight though and pretty easy, a script may look like this:
var allRelation = finder.findByType(Metamodel.safetyModel.CausalityRelation);
var affected = allRelation.filter(function(r) { return !r.context.isEmpty(); });
alert("" + affected.size() + "/" + allRelation.size() + " of all causality relations have a context. Now fixing...");
affected.forEach(function(r) { r.context.clear(); });
I also attached a script with the same code.
Happy Removal
Jan