Book a Demo

Author Topic: API access of Taggedvalues for packages  (Read 8631 times)

Ulf Gebhardt

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
API access of Taggedvalues for packages
« on: September 18, 2013, 05:25:01 pm »
I need to modify/create/access taggedvalues for EA package objects via the API.
For EA element objects this is easily done via the IDualElement interface, which has a TaggedValues Member.
But the IDualPackage Interface doesn't have this member.
So my question is:
How can I handle the taggedvalues for a package with the API.

Thanks, Ulf

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: API access of Taggedvalues for packages
« Reply #1 on: September 18, 2013, 05:40:03 pm »
Dear Ulf

a package consists of the container and the package element.

You can get/create/modify the package tagged values with

package.Element.taggedvalue

Best regards

Stefan
« Last Edit: September 18, 2013, 05:40:50 pm by sethordefaye »
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: API access of Taggedvalues for packages
« Reply #2 on: September 18, 2013, 08:00:37 pm »
Have a look in my Scripting book. It details all the basics you need. (And of course Stefan is correct.)

q.

Ulf Gebhardt

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: API access of Taggedvalues for packages
« Reply #3 on: September 18, 2013, 08:52:00 pm »
Dear Stefan,

thanks for your answer. With myPackage.Element.TaggedValues I can easily access existing Tagged Values.
Unfortunately creating a new TaggedValue does not work in this way.
I tried myPackage.Element.TaggedValues.AddNew("myTag", "myValue"), and myPackage.Update() but this does not modify the package.  :o
Is there any other way to create new TaggedValues for a package??

Best Regs,
Ulf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: API access of Taggedvalues for packages
« Reply #4 on: September 18, 2013, 09:51:31 pm »
Just a wild thought, have you tried myPackage.Element.Update() after adding a tagged value?

Geert

Ulf Gebhardt

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: API access of Taggedvalues for packages
« Reply #5 on: September 18, 2013, 10:11:20 pm »
Hi Geert,

thanks for the idea, but I have tried this.
What seems to fail is this
>>myPackage.Element.TaggedValues.AddNew("myTag", "myValue")<<

Thanks Ulf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: API access of Taggedvalues for packages
« Reply #6 on: September 18, 2013, 10:27:12 pm »
Do you have anything in Repository.GetLastError()?

Also, make sure you reload the package before checking whether your script worked.

Geert

Ulf Gebhardt

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: API access of Taggedvalues for packages
« Reply #7 on: September 19, 2013, 12:23:15 am »
Thanks for your advice. I have found the problem:
I was missing the Update of the newly created TagValue Element. And of course this has to be followed by a myPackage.Element.TaggedValues.Refresh().

Thanks
Ulf  :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: API access of Taggedvalues for packages
« Reply #8 on: September 19, 2013, 03:28:36 pm »
Of course, makes sense. ::)

Geert