Author Topic: Error with the EA api version 16.1  (Read 101 times)

emiliano.davila

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Error with the EA api version 16.1
« on: November 23, 2022, 11:38:34 pm »
Hello everyone.
We are developing an addin and we started using EA version 16.1, and with this version we noticed a change in the operation of a function of EA, specifically "GetElementByID()".
It turns out that in a specific case we have "ghost" elements that do not have a Package_ID, this is useful for the addin, but when we want to use the function GetElementByID() with an element without Package_ID we get the following error



We see that the ID does exist and belongs to the element that we are looking for but still gives error



Does anyone know if this is a change in the operation or is an error? because this same function (same addin) with previous versions works correctly.

qwerty

  • EA Guru
  • *****
  • Posts: 12966
  • Karma: +370/-298
  • I'm no guru at all
    • View Profile
Re: Error with the EA api version 16.1
« Reply #1 on: November 23, 2022, 11:46:51 pm »
Maybe they changed it. Notes are usually not visible in the browser but only in diagrams. In the past they were moved to the package where the diagram resides. But basically it does not belong to the package. Having them without (PackageID = 0) seems more plausible (and should have been this way all time).

However, it might also be some mis-behaving add-in or script. I have not looked into V16 since V17 is not available. Just try yourself and create more notes and see where they end up.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12048
  • Karma: +469/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Error with the EA api version 16.1
« Reply #2 on: November 23, 2022, 11:47:03 pm »
They did change something with regards to those get operations. In some cases they now throw an exception instead of returning null.

But in this case, I think it's more like an internal change in the way the API gets objects. If an object doesn't have a packageID, it should not exist.
The GUI will not show you this object, and the Project Integrity Check will rescue these orphans and give them a new home (package).

So I'm afraid your "elements without a package) workaround is simply a wrong approach that needs refactoring.
(also, what happens if someone creates a second object with he name "ColoresAddinGobiernoDinamico"?)

Geert

PS. There is a faster way to get elements based on a query. You can use Repository.GetElementSet(query, 2). That saves you the trouble of parsing the XML, getting the ID, and a roundtrip to the database to get the object.


emiliano.davila

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Error with the EA api version 16.1
« Reply #3 on: November 25, 2022, 10:52:06 pm »
Thank you very much for your answers, in the end we opted for another method to perform the same function.