Book a Demo

Author Topic: Invisible tags and changed Type??  (Read 4617 times)

djdejong

  • EA User
  • **
  • Posts: 32
  • Karma: +2/-0
    • View Profile
Invisible tags and changed Type??
« on: November 29, 2016, 05:51:08 am »
I'm trying to define flows in a diagram by tagging elements.  If element1 and element3 are tagged with the "Tag" as "tagName" and the "Value" as "tagValue", I want to tag element2 identically:

BEFORE SCRIPT:
element1 (Tag: tagName; Value: tagValue) ---(sequence connector)--> element2 (Tag: X; Value: Y) ---(sequence connector)---> element3 (Tag: tagName; Value: tagValue)

AFTER SCRIPT:
element1 (Tag: tagName; Value: tagValue) ---(sequence connector)--> element2 (Tag: tagName; Value: tagValue) ---(sequence connector)---> element3 (Tag: tagName; Value: tagValue).

This is part of the code I've been playing with to make this happen:

if ((traverseNormal) and (not normalFound)) then
      dim weirdCounter : weirdCounter = 0
      'messin about
      for each connector in myElement.Connectors
         'initialize
         connectorClientID = connector.ClientID
         connectorSupplierID = connector.SupplierID      
         set clientElement = GetElementByID(connectorClientID)
         set supplierElement = GetElementByID(connectorSupplierID)
                        'make sure it's an outgoing connector
         if clientElement.Name = myElement.Name then
            'it's determined at this point that there's only one outgoing connector, therefore supplierElement is the next element
            for each myTag in supplierElement.TaggedValues
                   'I'm doing this because I wasn't sure how to use "supplierElement.TaggedValues.AddNew" properly
               while weirdCounter = 0   
               
                     myTag.Value = "Normal"
                     myTag.Name = "Path"
                     myTag.Update
                     weirdCounter = 1
                                                        'function returns the next element tagged accordingly
                     set getNextElement = supplierElement   
                     
               wend
               
            next            
         end if
      
      next
end if


It currently enters the code given the conditions and changes element2 in some way, but when I go to the diagram and check out element2's properties and the Tags table, it appears blank still.  However, the BPMN 2.0 (the diagram type I chose) table looks quite different and the "Type" is changed -- in the case where the elements are activities -- from "abstractTask" to blank.

A template fragment, as well as code running through element2's tagged values, recognizes that element2 has been tagged as I've intended, but I'm concerned about the changed Type and I'm bewildered as to why the tagged value is invisible to me within the properties dialogue.
« Last Edit: November 29, 2016, 05:53:02 am by djdejong »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Invisible tags and changed Type??
« Reply #1 on: November 29, 2016, 06:57:51 am »
A bit strange what you are doing. Use
Code: [Select]
tv = supplierElement.TaggedValues.AddNew("Path", "")
tv.value = "Normal"
tv.Update()
to create a new TV rather than overriding the first you find :-/

You need to reload the element/package after the change since EA will reflect the changes not immediately in the GUI. Use Repository.RefreshModelView(...) to do that.

q.

djdejong

  • EA User
  • **
  • Posts: 32
  • Karma: +2/-0
    • View Profile
Re: Invisible tags and changed Type??
« Reply #2 on: November 29, 2016, 07:09:29 am »
Ah yes - I know it's strange, I was trying to do what you showed but I didn't know how to do it and got impatient...I guess that ended up being ironic.  I was trying "...AddNew("Normal", "Path"), or something like that :P

Thanks for this. I'll try it out and get back.

djdejong

  • EA User
  • **
  • Posts: 32
  • Karma: +2/-0
    • View Profile
Re: Invisible tags and changed Type??
« Reply #3 on: December 06, 2016, 05:58:59 am »
Note to anyone that happens to read this, set tv = .... had to be used for it to work (also, refresh the tagged values of the element if you want those vlaues to apply later within the current execution of your code:

Code: [Select]
set tv = supplierElement.TaggedValues.AddNew("Path", "")
tv.value = "Normal"
tv.Update()
supplierElement.Taggedvalues.Refresh
« Last Edit: December 06, 2016, 06:48:46 am by djdejong »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Invisible tags and changed Type??
« Reply #4 on: December 06, 2016, 07:14:35 am »
Note that the Refresh is only needed if you are going to iterate the collection after the Update. The Update is right enough to save the changes.

q.