Book a Demo

Author Topic: Adding new relationships by script  (Read 4144 times)

brback

  • EA User
  • **
  • Posts: 21
  • Karma: +1/-0
    • View Profile
Adding new relationships by script
« on: March 04, 2017, 12:30:48 am »
I've been able to import applications and servers as elements into Sparx EA from a CMDB, but now I want to import the relationships as well. What class/method takes care of adding new relationships between two elements?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding new relationships by script
« Reply #1 on: March 04, 2017, 02:44:46 am »
element.Connectors is the right collection. Use this (pseudo) code:
Code: [Select]
connector = element1.Connectors.AddNew ("", "Dependency");
connector.SupplierID = element2.ElementID;
connector.Update ();

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Adding new relationships by script
« Reply #2 on: March 06, 2017, 08:11:05 pm »
... and to clarify: you only add (create) the connector to one element's Connectors collection. When you .Update() it, EA takes care of hooking everything up, after which the connector is present in the Connectors collections of both elements.

/U
My theories are always correct, just apply them to the right reality.