Author Topic: jArchi: getting relationships  (Read 52 times)

Hervé

  • Hero Member
  • *****
  • Posts: 369
jArchi: getting relationships
« 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  :-[

Code: [Select]
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é

Phil Beauvoir

  • Archi Master
  • Hero Member
  • *****
  • Posts: 922
    • Archi
Re: jArchi: getting relationships
« Reply #1 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
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Hervé

  • Hero Member
  • *****
  • Posts: 369
Re: jArchi: getting relationships
« Reply #2 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é