-2

I'm trying to loop up the hierarchy of an Enterprise Architect Model from a selected Node in JavaScript.
When I start with a Diagram within an Activity, the Diagram gives a valid ParentID (the Activity), but if I reach the Activity that returns 0 as a parent. If I manually go up further to the Package containing the Activity I can cycle up to the Model Root.
So somehow all Activities in the Project return ParentID 0, all other times seem to return a valid ParentID (apart from the Model of course, which is at the top).
Is there any chance to retrieve the Package Node within that the Activity is located?

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
user2144067
  • 122
  • 2
  • 7

1 Answers1

1

An EA.Element will only have a ParentID with a value different from 0 if it is owned by another EA.Element.

If the element is owned by a package you have to use the PackageID to get the corresponding package. You can do that using the operation EA.Repository.GetPackageByID()

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
  • Thank you. In understand the Downvote, as the PackageID was really next to ParentID. Next challenge (If I should create a dedicated question I'm happy to do this): Some Elements are embedded in a Diagram, but are actually linked as a "Bevavior". I'm now interested in the Path of the behavior and of its parent/package. I can see an implementation which seems to solve this inside EAAddin.cs, but it is using UmlToolingFramework. I would prefer to stick with the built in Javascript and have no external depencies. Is this possible then? – user2144067 May 05 '21 at 09:29
  • @user2144067 yeah, I can't really answer that in a comment, so you better ask a proper new question. Make sure to state exactly what you need, what you tried, and where you got stuck. And don't forget to include your code as well. – Geert Bellekens May 05 '21 at 09:35