Author Topic: Adding an Element to package "Invalid Type" error  (Read 3657 times)

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Adding an Element to package "Invalid Type" error
« on: April 01, 2015, 02:13:40 am »
I'm trying to add an Element to a newly created package from code.

My code is as following and it breaks at the Element AddNew and throws an error saying "Invalid Type".

                    packageName = "Requirements";
                    Package requirementPackage = parentpackage.Packages.AddNew(packageName, "Package");
                    requirementPackage.Update();

                    if (requirementPackage != null)
                    {
                        foreach (string elementName in ElementList)
                        {
                            Element myElement = requirementPackage.Elements.AddNew(elementName, "Element"); //Breaks here
                            myElement.Update();
                        }
                    }

Creating the package is no problem but that other error doesn't make sense to me.
Have I misunderstood something?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding an Element to package "Invalid Type" er
« Reply #1 on: April 01, 2015, 02:30:46 am »
"Element" is not a valid Element type.
Check the documentation on EA.Element. There a complete list of all accepted element types.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Adding an Element to package "Invalid Type" er
« Reply #2 on: April 01, 2015, 04:07:37 am »
Usually I don't plug my books directly, but you might save a bit of your time when reading/exercising my Scripting book.

q.