Book a Demo

Author Topic: Manage Elements - JavaScript fails!?  (Read 3638 times)

Florian Mühlbauer

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Manage Elements - JavaScript fails!?
« on: August 03, 2015, 06:02:00 pm »
Dear all,

I have a very simple script that creates a new element and then changes name + stereotype. I'm wondering why this script is working properly in JScript but is somehow "failing" with JavaScript.

With JavaScript there is no Script error but the new element name is not changing from “Foo” to “Bar”.
Is this a bug or am I doing something wrong?


Code: [Select]
!INC Local Scripts.EAConstants-JScript

function main()
{
      var thePackage as EA.Package
      var theElement as EA.Element
      
      thePackage = Repository.GetTreeSelectedPackage();
      
      theElement = thePackage.Elements.AddNew("Foo","Component")
      theElement.Stereotype = "output";
      theElement.Name = "Bar"
      theElement.Update;

      thePackage.Elements.Refresh();

}

main();

As I want to use JavaScript any hint would be appreciated.
My EA version is 11.1.1110

Thank you
Florian

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Manage Elements - JavaScript fails!?
« Reply #1 on: August 03, 2015, 08:29:13 pm »
Try changing
Code: [Select]
     theElement.Update;into
Code: [Select]
     theElement.Update();
Geert

Florian Mühlbauer

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Manage Elements - JavaScript fails!?
« Reply #2 on: August 03, 2015, 08:42:28 pm »
Thank you Geert!

My Problem is solved by adding the brackets ().