Book a Demo

Author Topic: Adding tagged values to a package  (Read 3566 times)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Adding tagged values to a package
« on: April 13, 2015, 10:25:14 am »
Okie kokie

I am trying to set tagged values of a Package Stereotype.

That is:

1. I have created a stereotype whose metaclass is "Package".
2. I am trying to set the tagged values using script.

My script looks like this:

[Line 1] Set thisPackage = targetPackage.Packages.AddNew(packageName, "")
[Line 2] Set packageElement = thisPackage.Element
[Line 3] packageElement.Stereotype = stereotypeName
[Line 4] packageElement.SynchTaggedValues profileName, stereotypeName

However, once the interpreter gets to [Line 3] it tells me that there is an "Object Required" error.
Presumably this means that the call on [Line 2] to get a reference to the Element that underlies the package has failed.

What I would expect [Line 2] to do is give me the reference to the element that corresponds to/underlies the newly created package.
From then, I expected to be able to set the stereotype and syn the tagged values just like I would with a normal element.

But....this doesn't seem to be the case.

If anyone can help, it would be greatly appreciated.

Cheers

Jays  :)

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Adding tagged values to a package
« Reply #1 on: April 13, 2015, 10:47:35 am »
Just off the top of my head - You will probably need to call Update() on the new Package before trying to access it's Element.  Would also suggest calling Update() on the Element before trying to synch the tagged values for your stereotype.  Example:
Code: [Select]
Set thisPackage = targetPackage.Packages.AddNew(packageName, "")
thisPackage.Update
Set packageElement = thisPackage.Element
packageElement.Stereotype = stereotypeName
packageElement.Update
packageElement.SynchTaggedValues profileName, stereotypeName