Book a Demo

Author Topic: Adding Tagged Value to Connection  (Read 2963 times)

jonassam

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Adding Tagged Value to Connection
« on: March 07, 2019, 01:01:57 am »
Hi!
I try to add a Tagged Value to a connection using the automation interface from a C# application to no success. I am able to add it to other elements, though not all, with Connectors being the most urgent. The lines of code I used are:
  EA.ConnectorTag tv = connector.TaggedValues.AddNew("Status", regStatus);
  tv.Update();
  connector.TaggedValues.Refresh(); 

I have also seen someone suggesting the following approach, which does not work neither:
  EA.ConnectorTag tv = connector.TaggedValues.AddNew("Status", "String");
  tv.Value = regStatus;
  tv.Update();
  connector.TaggedValues.Refresh(); 

I am able to set a Tagged Value on an element using the following construct:
  (element.TaggedValues.AddNew("Status", regStatus) as EA.TaggedValue).Update();
  element.TaggedValues.Refresh();

So I figure I have understood the way this is supposed to be done… :) But then, for Connections I just cannot get it to work. Anyone has any ideas?

Best regards,
Jonas

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding Tagged Value to Connection
« Reply #1 on: March 07, 2019, 01:31:41 am »
Jonas,

There is no need to call the Refresh() method, unless you want to iterate of the collection again, and you want to see the new member.

When I add a tagged value I always start with only a name

Code: [Select]
var tv = connector.TaggedValues.AddNew("tagName", "");
tv.Value = "tagValue";
tv.Update();
I never had any issues doing it like that.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding Tagged Value to Connection
« Reply #2 on: March 07, 2019, 06:33:08 am »
It's also a good idea to state the EA version you're using.

q.