Archi Forum

Discussion Boards => jArchi => Topic started by: Hervé on December 03, 2018, 16:50:21 PM

Title: jArchi: getting relationships
Post by: Hervé on December 03, 2018, 16:50:21 PM
Hi,

I'm currently playing around with jArchi, which is really a very powerful tool.

Unfortunately, I fail creating my first script  :-[


console.clear();
if ( model == null || model.id == null ) {
   console.log("Please select a model.");
} else {
   var all_app = $("application-component");

   all_app.each(function(app) {
      var relationships = app.rels();
   });
}


I'm having an error message
   Script Error at: javax.script.ScriptException, javax.script.ScriptException: TypeError: app.rels is not a function in file:/D:/---%20archi/test.ajs at line number 8

What I'd like to achieve is to loop on all the relationships (and also all the concepts at the end of those relationships).

What did I do wrong ?

Thanks in advance
Hervé
Title: Re: jArchi: getting relationships
Post by: Phil Beauvoir on December 03, 2018, 16:59:17 PM
Hi Hervé,

.rels() works on a collection of objects. So you if you are working with a single object, have to make a collection of one item by using $():

var relationships = $(app).rels();

Phil
Title: Re: jArchi: getting relationships
Post by: Hervé on December 03, 2018, 19:37:02 PM
Hi Phil,

Thank you very much ... It is effectively noted in the wiki that it works on collections, but as I've nover done Javascript, I did not notice that my variable was not a collection.

Best regards
Hervé