createRelationships - Cannot cast com.archimatetool.script.dom.model.DiagramMode

Started by René, March 01, 2021, 17:03:52 PM

Previous topic - Next topic

René

I wanna create relationships of selected item - if there is a same named item by another type:

$(selection).filter("resource").each(function(obj){

name = "." + obj.name;
console.log(obj, name);

$(name).filter("course-of-action").each(function(obj2)
{
console.log("-", obj, obj2);
model.createRelationship("triggering-relationship", "triggers", obj, obj2);
});
});


I got this message:

Script Error: java.lang.ClassCastException: Cannot cast com.archimatetool.script.dom.model.DiagramModelObjectProxy to com.archimatetool.script.dom.model.ArchimateConceptProxy

I have no glue.

Jean-Baptiste Sarrodie

Hi,

I suspect you launched this script after having selected items in a view and not the model tree. This means that you're trying to create a relationship involving a view object (obj) and not the concept itself (obj.concept). so simply replace obj by obj.concept.

Another remark: $(name).filter("course-of-action") can be replaced by $("course-of-action"+name).

Regards,

JB

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.